1

the \kartik\grid\EditableColumn widget has a parameter called ajaxSettings where you may override the parameters passed with the ajax request to the server. What i want to do is to dynamically pass the selected rows ids together with the value coming from the popover to the server. I manage to do that passing static parameter coming from a php array in compile time like so

Editable::widget(['name' => 'publishDate', 'ajaxSettings' => ['ids' => [1,2,3]]])

but It seems that i cannot use a jquery selector there to grab the ids of the selected columns like so

Editable::widget([
    'name' => 'publishDate', 
    'ajaxSettings' => [
        'ids' => '$("#books-grid").yiiGridView("getSelectedRows")'
    ]
])
silintzir
  • 762
  • 1
  • 6
  • 13

1 Answers1

0

Maybe you want to try creating a variable outside the Editable::widget([ like this:

var arrayIds = $("#books-grid").yiiGridView("getSelectedRows");

And then assign it to the widget:

Editable::widget([
    'name' => 'publishDate', 
    'ajaxSettings' => [
        'ids' => arrayIds
    ]
])

Hope this helps,

Leo.

Leo
  • 956
  • 8
  • 24
  • I tried to, but the ids come dynamically from the selected checkboxes of the grid and this seems to break the override of the data parameter in the ajax call. – silintzir Oct 11 '16 at 07:10
  • I believe that you need to convert the array from the yiiGridView to an indexed array? Could you try converting the array to an indexed array using this function? newArray = $.makeArray( arrayIds ); – Leo Oct 11 '16 at 16:52