Revision #5 has been created by toaster on Nov 21, 2018, 7:01:13 PM with the memo:
resize final gif
« previous (#4) next (#6) »
Changes
Title
unchanged
Batch Gridview data ajax send splitted in chunks displaying bootstrap Progress bar
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
AJAX,gridview,Progressbar,batch data send
Content
changed
[...]
});
```
The first three functions take care to show, update and hide the progress bar inside the modal window, while the `batchSend` function perform the array split and, using recursion, send the data through post ajax request, encoding the array as JSON string and calling itself until there is no more chunks to send. The last lines of code bind the click event of the `#batch_process` button checking if at least one row of Gridview has been selected. The number of elements on each array chunk can be set as the third argument of the `batchSend` function (in my case 5), you can adjust it accordingly. The first parameter is the whole array obtained by the `yiiGridView('getSelectedRows')` function.
The final result is something like this:
<img src="https://www.dijackfantasy.com/batch_send1.gif"
style="width:150%" />
...looks cool, isn't it?