Git Product home page Git Product logo

Comments (2)

tabalinas avatar tabalinas commented on July 21, 2024

Filtering should be always implemented by developer. It may be implemented whether on client or server side. On client side we put filtering logic into controller method loadData. On the server side (more common) we pass filter parameters to the server script and apply filtering on server side to avoid transferring of unnecessary data to the client. Thus there is no difference between loading by page and direct loading in case of filtering.

Sorting is really differ for direct loading and loading by page. Direct loading sorts data of the grid. Loading by page strategy just reloads data providing paging parameters to the filter argument of controller loadData method (pageIndex current page index and pageSize - current page size from grid config). Why it happens this way: loading by page makes sense only when you implement all filtering and sorting logic on the server side, when you have big amount of data. Just imagine you've loaded only first page, does it really make sense to sort only this first page items? Sorting of all data can be implemented only on the server side, because grid just don't have other data.

Possible solution
Anyway, if you wish sorting of data on the current page, it's doable.
All the difference in behavior between loading by page and direct loading is extracted to loadingStrategies (didn't have time yet to describe this advanced info in docs).

    jsGrid.loadStrategies = {
        DirectLoadingStrategy: DirectLoadingStrategy,
        PageLoadingStrategy: PageLoadingStrategy
    };

The direct loading strategy does following on sorting:

    sort: function() {
        this._grid._sortData();
        this._grid.refresh();
        return $.Deferred().resolve().promise();
    }

The loading by page strategy has another implementation:

    sort: function() {
        return this._grid.loadData();
    }

All you need to do is to redefine loading by page strategy behavior (of course, it's possible to create your own loading strategy but it's more complicated than just override sort method):

    jsGrid.loadStrategies.PageLoadingStrategy.prototype.sort = function() {
        this._grid._sortData();
        this._grid.refresh();
        return $.Deferred().resolve().promise();
    }

See following fiddle to see how it works http://jsfiddle.net/tabalinas/z39qvxoc/

from jsgrid.

hrmshandy avatar hrmshandy commented on July 21, 2024

thanks for solution :)

from jsgrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.