Hello,
I have enabled paging on my grid. I am facing following issues:
1. If I am on the last page and there is only one record on the last page. And if I delete that record from the grid. The grid doesn't go to the previous page automatically.
2. If:
total pages are: 9
pages size is: 10
total rows count is: 81
current page index is: 3
Now, if I delete a record from the page no. 3, then the pager is not automatically refreshed. And it still shows the total 9 pages. Ideally it should recalculate the total pages and show 8 pages.
I delete the row using the following code (is it the correct way to delete a row?):
$("#FWUserGrid").igGridUpdating("deleteRow", 123);
Any ideas how to achieve this behavior?
Regards,
Arfan Baig
Hello guys,
Thank you for posting in our community.
To achieve the required behavior it is needed to rebind the grid to the updated data source. As Michael said the autoCommit option should be enabled and then the page containing the grid should be reloaded again. While reloading the page the grid will be rebound with the actualized data source.
In order to optimize the process you could either use an ajax call to refresh just the part of the page containing the grid or if the project is an MVC partial paging might be implemented.
Hope this helps.
That functionality depends on the autoCommit option of your grid I believe.
You may need to do a databind after that as well. Try this after the delete. You will probably need to store the page number of the grid you are on and set it after the dataBind as well. Try something like this possibly. Hope it helps.
var yourPageNumber = $("#grid").igGridPaging("pageIndex");
var yourPageSize = $("#grid").igGridPaging("pageSize");
$("#grid").igGrid("dataBind");
var yourLocalRecordCount = $("#grid").data("igGrid").dataSource.totalLocalRecordsCount();
var maxPage = Math.ceil((double)yourLocalRecordCount / yourPageSize);
yourPageNumber = (yourPageNumber > maxPage) ? maxPage : yourPageNumber;
$("#grid").igGridPaging("pageIndex", yourPageNumber);