Coder Social home page Coder Social logo

Get Selected Rows about yii2-dynagrid HOT 7 CLOSED

kartik-v avatar kartik-v commented on June 4, 2024
Get Selected Rows

from yii2-dynagrid.

Comments (7)

kartik-v avatar kartik-v commented on June 4, 2024

Hope you have read the default yii guide. You may once want to do that.

This is addressed in yii\grid\CheckboxColumn... you need to write your javascript accordingly.

The selected rows may be obtained by calling the following JavaScript code:

var keys = $('#grid').yiiGridView('getSelectedRows');
// keys is an array consisting of the keys associated with the selected rows

This is also highlighted in the Krajee Grid Documentation for Checkbox Column.

from yii2-dynagrid.

dudunegrinhu avatar dudunegrinhu commented on June 4, 2024

@kartik-v I already tried that but it gives me an error:

TypeError: $(...).yiiGridView is not a function

from yii2-dynagrid.

kartik-v avatar kartik-v commented on June 4, 2024

The error means you are using a wrong identifier for your grid. The HTML ID attribute must pertain to your gridview container.

For Dynagrid you set gridview widget properties via gridOptions - hence you can access the grid ID attribute through gridOptions['options']['id']. You may need to set a value for this and access. For example:

// widget php script
echo Dynagrid::widget([
    'options' => ['id' => 'dynagrid'], // this is dynagrid identifier
    'gridOptions' => ['options' => ['id' => 'grid']], // this is gridview identifier
    // add other settings required by DYNAGRID
]);

Then access the same via javascript.

// js script
var keys = $('#grid').yiiGridView('getSelectedRows');
// keys is an array consisting of the keys associated with the selected rows

from yii2-dynagrid.

dudunegrinhu avatar dudunegrinhu commented on June 4, 2024

@kartik-v if I fix my javascript, it was because was inside the domready but now when I get the selected rows I get this error:

TypeError: data is undefined
if (data.selectionColumn) {

from yii2-dynagrid.

dudunegrinhu avatar dudunegrinhu commented on June 4, 2024

Sorry @kartik-v it worked now, it was a conflict name on both id's.
Thanks for the clarification. I would like to make a donation to you because I'm using a lot of your components and if you have the time I would like to hire you as a consultant.

from yii2-dynagrid.

ikramadjissa avatar ikramadjissa commented on June 4, 2024

I get this error :
Setting unknown property: kartik\grid\GridView::gridOptions

from yii2-dynagrid.

mohalaika avatar mohalaika commented on June 4, 2024

thanks a lot it's working fine
but if you may how I get the full row data using the key?

from yii2-dynagrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.