0
votes

I've been doing a LOT of googling, but couldn't find a way to implement this. Sorry if I missed it in my searching.

I used Example 4 adding tree functionality as a template, but I've been unable to implement column sorting while tree functionality is active.

Everything I've tried winds up in an infinite loop in the rendered version of my inline filter due to the IDs no longer being in order.

Has anyone been able to implement sorting with tree functionality or have any pointers how it can be accomplished? Is there a way to sort the parent rows and leave the parents and children together?

My filter is basically the same as the one in the example with some minor tweaks to the search.

It gets stuck looping the item.parent if since the parents and children are no longer sequential. Now all rows have children.

if (item.parent != null) {
            var parent = oppLineGridData[item.parent];

            while (parent) {
                if (parent._collapsed) {
                    return false;
                }

                parent = oppLineGridData[parent.parent];
            }
        }

Full function:

function openFilter(item) {

        if (specificColumn != null) {
            if (searchString != "" && item[specificColumn].toLowerCase().indexOf(searchString) == -1) {
                return false;
            }

        } else {
            if (searchString != ""
                && item["accountName"].toLowerCase().indexOf(searchString) == -1
                && item["solution"].toString().toLowerCase().indexOf(searchString) == -1
                && item["Adjusted_Commitment__c"].toLowerCase().indexOf(searchString) == -1
                && item["Deal_Registration_ID__c"].toLowerCase().indexOf(searchString) == -1
                && item["lineItemValue"].toString().toLowerCase().indexOf(searchString) == -1
                && item["oppotunityName"].toLowerCase().indexOf(searchString) == -1
                && item["closeDate"].toLowerCase().indexOf(searchString) == -1
                && item["productName"].toLowerCase().indexOf(searchString) == -1
                && item["stageName"].toLowerCase().indexOf(searchString) == -1
                && item["ownerName"].toLowerCase().indexOf(searchString) == -1
                && item["accountManagerList"].toLowerCase().indexOf(searchString) == -1
                && item["accountManagerMgr2"].toLowerCase().indexOf(searchString) == -1
                && item["ProServicesEngagement"].toLowerCase().indexOf(searchString) == -1
                && item["proServicesEngagementAll"].toLowerCase().indexOf(searchString) == -1
                && item["productType"].toLowerCase().indexOf(searchString) == -1
                && item["commissionableEMName"].toLowerCase().indexOf(searchString) == -1
                && item["lastUpdated"].toLowerCase().indexOf(searchString) == -1
                && item["updatedBy"].toLowerCase().indexOf(searchString) == -1) {
                return false;
            }
        }
        if (item.parent != null) {
            var parent = oppLineGridData[item.parent];

            while (parent) {
                if (parent._collapsed) {
                    return false;
                }

                parent = oppLineGridData[parent.parent];
            }
        }

        return true;
    }
1

1 Answers

1
votes

The only answer is to disable the inlining of filters. In other words, the option inlineFilters should be set to false. I just suffered from the same issue and I tell you this from the experience. The inlining of filters for SlickGrid won't handle complex code. Even a for with an if inside or a inner loop was enough for it to go into infinite loop for me.