Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
830
igGrid customSortFunction not working with 17.1
posted

My igGrid has a feature of Sorting like below, but when I am doing customSortFunction it doesnot rebind the sorted data to grid.

I did check data = _.orderBy(data, ['cat2_Sector_sort', 'issuer_description'], ['asc', 'desc']); is sorting data correctly but not getting bind to grid

This code was working when my version of infragistics was 16.1, I am upgrading it to 17.1.

{
name: "Sorting",
customSortFunction: sortHoldingDetails
},

var sortHoldingDetails = function (data, fields, direction) {
var dir = "asc";
var colKey = fields[0].fieldName; //colKey gets changed below in code and both fields[0].fieldName and colKey are used below
if (direction == "descending") {
dir = "desc";
}
data = _.orderBy(data, ['cat2_Sector_sort', 'issuer_description'], ['asc', 'desc']);
return data;
}

Parents
No Data
Reply
  • 17590
    Offline posted

    Hello jconning,

    Thank you for posting in our community.

    I am attaching a small sample where custom sorting function is applied. This sample uses version 17.1 and everything is working as expected. I am using the following custom sorting function:

    var myCustomFunc = function (data, fields, direction) {
                    if (fields[0].fieldName === "ProductID") {
                        function myCompareFunc(obj1, obj2) {
                            if (direction == "descending") {
                                return obj2[fields[0].fieldName] - obj1[fields[0].fieldName];
                            }
                            return obj1[fields[0].fieldName] - obj2[fields[0].fieldName];
                        }
                        var result = data.sort(myCompareFunc);
                      
                        return result;
                    }
                    return data;
                }

    Please test my sample on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it, in order to reproduce the issue, and send it back to me along with steps to reproduce. This is going to be highly appreciated and will help me in my further rinvestigation.

    Looking forward to hearing from you.

    igGridCustSortingFunction.zip
Children
No Data