Difference between #1 and #6 of
Batch Gridview data ajax send splitted in chunks displaying bootstrap Progress bar

Changes

Title unchanged

Batch Gridview data ajax send splitted in chunks displaying bootstrap Progress bar

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags changed

AJAX,gridview,Progressbar,batch data send

Content changed

[...]
```
The code for the controller action is the following:

/**
* Process an array of codes
* @return mixe
sd
* @throws BadRequestHttpException if the request is not ajax
*/
[...]
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" />
 
...looks cool, isn't it?
8 0
2 followers
Viewed: 33 128 times
Version: 2.0
Category: Tutorials
Written by: toaster
Last updated by: toaster
Created on: Nov 21, 2018
Last updated: 5 years ago
Update Article

Revisions

View all history