Hi,
I am using Grid with Batch mode editing (only allows editing on some columns but no addition or deletion of rows) and has pagination, row drag and drop enabled.
The ordering of rows on the screen is important to my use case, and are sorted on a data field "rowOrder" by default (hidden column). When the user moves the rows around, I want to be able to update the rowOrder for all the rows on the grid, and send the new values back for the update. The new rowOrder field would essentially be the rowIndex on the grid.
Couple of things here:
Can you please help?
Thanks!
Hi Tera,
Greetings from Syncfusion support.
Currently, we are validating your query “Save row order after row drag/drop in Grid Batch editing mode” with shared information. We will update further details on or before 10th October 2022.
Until then, we appreciate your patience.
Regards,
Vinitha Balasubramanian
Hi Tera,
Thanks for your patience.
Query 1 : Is there a way to set it for the entire data set across multiple pages?
We have analyzed your query, we need some more information for our clarification. Before we start providing solution to your query, kindly share the below details that will be helpful for us to provide better solution.
Query 2 : To updates to the field columns while performing row drag and drop.
We have prepared a simple sample to achieve your requirement using setCellValue method and rowDrop event of Grid component. Kindly refer the below code and sample for more information.
[index.js] function rowDrop(e) { setTimeout(() => { for (let i = e.fromIndex; i <= e.dropIndex; i++) { console.log(grid.getRowInfo(grid.getRowByIndex(i))); grid.setCellValue( grid.getRowInfo(grid.getRowByIndex(i)).rowData['slNo'], 'rowIndex', i + 1 ); } grid.refresh(); }, 10); setTimeout(() => { for (let i = e.dropIndex; i <= e.fromIndex; i++) { console.log(grid.getRowInfo(grid.getRowByIndex(i))); grid.setCellValue( grid.getRowInfo(grid.getRowByIndex(i)).rowData['slNo'], 'rowIndex', i + 1 ); } grid.refresh(); }, 10); } |
Sample : https://stackblitz.com/edit/xxwq8z?file=index.js%3AL85,index.html
Regards,
Vinitha Balasubramanian
Hi Vinitha,
Thanks for you response.
Hi Tera,
Thanks for your update.
Currently, we are validating your reported problem with your shared information, and we will update you the details on or before 14th Oct 2022. Until then we appreciate your patience.
Regards,
Vinitha Balasubramanian
Hi Tera,
Thanks for your patience.
We have analyzed your shared information, we need some more information for our clarification. Before we start providing solution to your query, kindly share the below details that will be helpful for us to provide better solution.
Regards,
Vinitha Balasubramanian
Hi Vinitha,
Thank you for your response.
Hi Tera,
Thanks for your update.
Currently, we are validating your reported problem with your shared information, and we will update you the details on or before 20th Oct 2022. Until then we appreciate your patience.
Regards,
Vinitha Balasubramanian
Hi Tera,
Thanks for your patience.
We have prepared a sample to update the rowOrder for the entire dataSource using rowDrop event of Grid component. Kindly refer the below code and sample for your reference.
[index.js]
function rowDrop(e) { setTimeout( function () { for (var i = 0, len = this.dataSource.length; i < len; i++) { this.dataSource[i].rowOrder = i + 1; } this.refresh(); }.bind(this), 100 ); } |
Sample: https://stackblitz.com/edit/xxwq8z-ivbtta?file=index.js,index.html
Please get back to us if you need further assistance.
Regards,
Vinitha Balasubramanian
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Hi Vinitha,
Thank you for your response. We also have editing enabled in the grid as I mentioned earlier. If I add the following to the example above,
the 'Update' button in the toolbar does not get enabled for me on the rowDrop. I tried enabling the same in the rowDrop method via following but didn't help.
Also, the changes should get passed to the backend with other changes via :
grid.getBatchChanges().changedRecords
Thanks!
Hi Tera,
Greetings from Syncfusion support
In our previous update, we have updated the data directly to the datasource and achieved your requirement. Now you are enabling editing in the Grid and and like to perform the rowDrop and maintain the row order. Before we start providing solution to your query, please share the below details that will be helpful for us to provide better solution.
1) Share your exact requirement step by step with detailed description.
2) Share type of data binding used(local data or remote data).
3) If remote, please share what adaptor you are using in your application.
4) Please confirm you like to update the rowOrder using batch editing.
5) Please confirm using batch editing you like to update the row order value on row drop for all page or current page alone, because the batch editing sends the modified data to the backend
only for the current page alone.
Regards,
Rajapandi R