KoGrid icon indicating copy to clipboard operation
KoGrid copied to clipboard

self.sortData has javascript error 'sortInfo is not defined' in 2 spots

Open davidjsilva opened this issue 12 years ago • 6 comments

self.sortData = function (col, direction) {
        // if external sorting is being used, do nothing.
        self.isSorting = true;
        self.sortInfo({
            column: col,
            direction: direction
        });
        self.clearSortingData(col);
        if(!self.config.useExternalSorting){
            window.kg.sortService.Sort(sortInfo, self.sortedData);
        } else {
            self.config.sortInfo(sortInfo);
        }
        self.lastSortedColumn = col;
        self.isSorting = false;
    };

The sortInfo variable is not defined and therefore throws a javascript Uncaught ReferenceError: sortInfo is not defined. You can see it in the following fiddle as well - http://jsfiddle.net/zSpMh/2/ after you try sorting the first column.

davidjsilva avatar Dec 19 '12 18:12 davidjsilva

This should fix the issue :). Thanks for finding that!

orneryd avatar Dec 19 '12 18:12 orneryd

OK so after that fix my computed function which responds to any changes to sortInfo gets called twice. See fiddle console log for example http://jsfiddle.net/zSpMh/3/. Do I have to change the way I do my computed function? Or maybe does that new hotfix need to change?

davidjsilva avatar Dec 19 '12 18:12 davidjsilva

I want to say that self.sortInfo has a reference to self.config.sortInfo because if you evaluate self.sortInfo() === self.config.sortInfo() in that self.sortData function it always evaluates to true. Not sure if that helps.

davidjsilva avatar Dec 19 '12 18:12 davidjsilva

I'll look into it, I am going to change the title but it should only get called once.

orneryd avatar Dec 19 '12 20:12 orneryd

I'm also getting into the same problem. The serverside sorting gets called twice.

Thanks for KoGrid, BTW. :)

ms440 avatar Dec 21 '12 00:12 ms440

sortInfo gets called twice, is this issue fixed?

kkandala avatar Oct 18 '13 21:10 kkandala