Hello,
I have implemented server side sorting and paging in Ignite Grid (using MVC wrappers). I need to sort by a specific column using the Grid's API. At the same time I need to jump to a specific Page Index using the Grid's API.This causes two service calls; which I need to avoid.
How can I make the Grid to go to the server only once for these two operations?
One work-around that I ve already tried was to return false from the dataBinding event for the sorting and then return true when setting the page index. But, this doesn't work - the sorting information is not sent to the server.
NOTE: In near future I also need to filter the Grid using the API; and I would want to generate only a single call to the server for all these three operations. So, I am in a big need of a solution to this problem.
Urgent help shall be appreciated.
Regards,
Arfan Baig
Hello Arfan,
You can use $.ig.DataSource.urlParamsEncoding handler in order to modify any remote feature parameters.
For more details you can check the following forum post: http://ko.infragistics.com/community/forums/p/75870/383316.aspx#383316
Hope this helps,Martin PavlovInfragistics, Inc.
Hello Martin,
Thanks for providing the solution.
I have created the dataSource object as you have suggested. But, since I am using the MVC wrapper, I am not sure how do I use this dataSource object. I have tried the following but its doesn't seem to work:
var ds = new $.ig.DataSource({ dataSource: url, responseDataKey: "Source", urlParamsEncoding: function (owner, params) { owner.settings.sorting.expressions.push({ fieldName: "Name", dir: "desc" }); owner.settings.paging.pageIndex = 1; return true; } }); $(gridSelector).igGrid("option", "dataSource", ds); $(gridSelector).igGrid("dataBind"); Is it the right approach? Please note that I can't set the dataSource object to while initializing since I am already using the DataSourceUrl there. Also, I need to apply these operations only once at the page load only.
Please suggest what should I do to get it working?
Secondly, I was wondering if I can get the urlParamsEncoding event when I have used the DataSourceUrl in my Grid (using MVC Wrapper)?
I have managed to get it working.However, I would strongly request you to give feedback on the approach I have described above. Please suggest if there is better way to do this.
Secondly, I have now started facing few more issues:
1. Setting the new dateSource (which contains new page index) and dataBinding takes me to the required page. But, the pager still keeps showing page index: "1". How do I put correct page-index in the pager.
2. When the page loads, the Grid automatically makes a server call to get the data for the first page (page-index:0). After that it makes a second call to the server when I set the new dataSource into it and dataBind it. I want to avoid the first call since it is completely unnecessary. How do I avoid the first call to the server?
One work-around that I tried was to return false from the dataBinding event for the first time and return true afterwards. But, then it never goes to the server for data.
Thank you for your cooperation in anticipation.
Any update on this?