Hi,
Can I maintain the state of igGrid. Suppose the user is on Page 2 in grid and with filter set on one column.
Next time user visited the same page and I bind data and set page number 2 and filter row open and fill the filer column textbox with the same old value
Hi Martin,
I'm currently implementing " Filtering - Excel Style in igGrid" as suggested by you in http://es.infragistics.com/community/forums/t/70068.aspx?PageIndex=2 in our ASP.NET MVC4 application.
Its working perfectly on that page.
However, we are also maintaining state in igGrid when user comes back to the grid page. State is getting maintained for multiple Single drop-down filters (i.e. user select one city, one Company name for filtering. I'm not able to do the same for multiple select in same filter column.
Say user selects "London" and then selects "Nantes". When user comes back to the same page, filter shows "Nantes" as selected. However, cookie maintained for the same has both filtering expressions (
{"fieldName":"City","expr":"London","cond":"equals","logic":"OR"},{"fieldName":"City","expr":"Nantes","cond":"equals","logic":"OR"}
{"fieldName":"City","expr":"London","cond":"equals","logic":"OR"},{"fieldName":"City","expr"
:"Nantes","cond":"equals","logic":"OR"}
).
I get that for multiple filter selection across columns we are using igDataSource.settings.filtering.customFunc handler.
How can I put this logic in SetExistingFilter() javascript function which we call on 'iggridrendered' grid event?
Current implementation on 'iggridrendered' grid event is as follows: $('#igGrid1').live('iggridrendered', function (event, args) { SetExistingFilter(); $("#igGrid1").data("igGrid").dataSource.settings.filtering.customFunc = customFilterHandler; });
Yes it worked! I was actually reading pageIndex cookie after setting pageSize. Hence it was resetting my cookie value to 0.
So, reading before pageSize and setting immediately after pageSize works for me.
Thanks!
Hi Peter,
Internally pageSize resets pageIndex to 0, because it didn't try to guess what might be the actual pageIndex based on previous page size and new page size.
However if you call pageIndex method after pageSize method you'll get the expected behaviour.
Here is an example code:
$("#grid1").igGridPaging("pageSize", 20); $("#grid1").igGridPaging("pageIndex", 2);
Hope this helps,
Martin Pavlov
Infragistics, Inc.
I tried above solution for maintaining state of the grid. I need to maintain filter, sort, page index and page size in the grid.
It works very well for filter ans sort settings.
However, if I try to maintain page size along with page index, page size resets page-index to 0.
Without page size maintenance, page index state gets maintained.
Is there any way to maintain page size along with current page index?
You can use cookies to persist features states.
For example you can get igGridPaging pageSize/pageIndex properties on igGridPaging.pageIndexChanged and igGridPaging.pageSizeChanged events and then create/update cookie.
When the user returns to the same page get the cookie value and use it to restore the paging state.
For filtering you can get the current filter on igGridFiltering.dataFiltered event with this code:
var filteringExpressions = $("#grid1").data("igGrid").dataSource.settings.filtering.expressions;
and then create/update cookie.
When the user returns to the same page get the cookie value and restore the filtering state by using the igGridFiltering.filter method.