On an igTreeGrid, I'm noticing that the rendered event is continuously fired, and I get a max stack call exceeded error if I programmatically set the filter in the event handler. If I comment the set filter code the rendered event is triggered only once.
var renderedHandler = function(event, ui) {
var customFilters = @(Html.Raw(Json.Encode(Model.Filter.CustomFilters))); if (customFilters != null && customFilters != "") { $("#grid").igTreeGridFiltering('filter', (customFilters)); }
}
My customFilters is - [{ fieldName: 'Location', expr: 'dfw', cond: 'contains' }, { fieldName: 'Market', expr: 'z17', cond: 'contains' }]
For test purpose, I tried explicitly setting the filter on a button click event after the grid is loaded, and it works.
Just FYI - The grid is created on a table and not a div tag.
What is the recommended way to apply the filter ??
Appreciate the follow up.
I was able to trigger applying the filter by triggering a button click event.
Thank you very much for your help.
Hello C R,
The best way for me to assist you further is if you provide a small isolated sample that I can run and use for debugging locally.
Regards,
Tsanna
Appreciate the response.
I'm now receiving - Cannot read property 'key' of null.
Here is what I'm doing per your suggestion. After the igTreeGrid is rendered, I'm triggering applying the filter on a button click.
The filter works if I have the filter explicitly entered.
Scenario 1 -
var customFilters = @(Html.Raw(Json.Encode(Model.Filter.CustomFilters)));if (customFilters != null && customFilters != "") { $("#page-tree-grid").igTreeGridFiltering('filter', ([{fieldName:'Location', expr:'dfw', cond:'contains'}])); }
I receive "Cannot ready property 'key' of null" if I do this..
Scenario 2 -
var customFilters = @(Html.Raw(Json.Encode(Model.Filter.CustomFilters)));if (customFilters != null && customFilters != "") { $("#page-tree-grid").igTreeGridFiltering('filter', (customFilters)); }
I have confirmed that my customFilters variable contains exactly the expression hardcoded in Scenario 1.
Driving me insane on what could be different. I definitely cannot go with hardcoding filter expression.
Please advice.
Have also attached the screen shot of error.
It's not recommended to call data manipulation methods inside grid rendered event, because most of them are calling an internal method called _renderData that causes the rendered event to trigger in an unlimited loop resulting in error like the one you got. Instead I would suggest you either to call your custom filters using for example button click event, or call the filter API after grid is initialized, or follow this forum post for more ideas: https://ko.infragistics.com/community/forums/t/79873.aspx
Please let me know, if you need further help.
Anyone...