I have a column defined with a custom sort strategy. That is working fine when I manually sort the column. However I added sortingExpressions so that it would be sorted in first place by default. That isn't using the custom sort strategy but instead just using the default sorting strategy. I tried adding the strategy to the object passed in for sortingExpressions but its still not calling it.
I have:
How can I use my custom sort strategy with the sortingExpressions?
Thanks
Hello Katy,
Thank you for contacting Infragistics Community!
I have investigated the described behavior and I believe you will find the following sample I have prepared for you very helpful. As you can observe I’m passing a custom sorting strategy to the MarketNotion column. In order to be able to understand easier how this custom strategy operates I have templated the cells of the MarketNotion column so that on the left side you can observe the real values and on the right side - the values which is going to be compared and sorted. Using SortingExpressions I initially sort this column in descending order and I pass again the custom sorting strategy. As you can observe this is working exactly as expected and the custom strategy is applied. If this sample is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me for further investigation.
Looking forward to hearing from you.
Best Regards, Martin Evtimov Entry Level Software Developer Infragistics, Inc.
Thanks for the example. I have managed to figure out the problem is related to also using the state feature. What I have found is that when you save the state it does this
getFeatureState(context) { const sortingState = context.currGrid.sortingExpressions; sortingState.forEach(s => { delete s.strategy; delete s.owner; }); return { sorting: sortingState }; },
So at that point the strategy is deleted. This seems to be wrong logic as I am not sure why saving state would remove the sort strategy. I understand the sort strategy cant be included into the json but it seems like it should be removing those from a clone rather than the actual. Since on page load I save initial state so that if they make changes they can restore the original view it means that my sort is always dropped. Since atm my state saves before the data loads once data is loaded its already lost it.