1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    4
    Vote Rating
    0
    mvairavan is on a distinguished road

      0  

    Default Unanswered: Paging in GridView

    Unanswered: Paging in GridView


    Hi,
    I want to a paging implemented in the Grid. all the example seems to be very complicated.
    I already have a store which is being attached to the grid.
    Isn't there a easy way to add paging to the store?

    After going through all the examples i feel like its easy to implement a paging myself rather than going through all those. All i want is a toolbar with few buttons which updates the current store and rest happens automatically.
    What is loadconfig, loadresult, proxy. i just dont understand it. Can anyone give a simple example?

  2. #2
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    Firstly, pagination dictates what segment of data you're viewing in the store. Secondly, a grid will by default display ALL items in it's store. Thirdly, I think you mean at the very least ListLoadConfig, ListLoadResult, and DataProxy since there are no loadconfig, loadresult, and proxy objects directly.

    ListLoadConfig allows you to indicate the sorting of the data in your grid. I.e., if you have sorting enabled on a column, when you click that column header, a List<SortInfo> is set on the ListLoadConfig.

    Since you want pagination, you actually want a PagingListLoadConfig, which in addition to sorting, has an offset and limit - essentially, starting at position <offset> give me <limit> pieces of data.

    The DataProxy class defines one method, load(...) which takes in a load config, in your case a PagingListLoadConfig, and a Callback. The Callback is what's called by the PagingLoader to fetch the data that is ultimately displayed in the grid.

    The ListLoadResult is just a container for the data that should be returned by your callback.

    Since you want pagination, you actually want PagingListLoadResult which also contains the offset from above, and the total number of items that would be returned were you to NOT do pagination. That is, if I have 100 items, my page size is 25, and my offset is 25, I would be on page 2 in my grid, and the PagingToolBar would display "page 2 of 4" and "Displaying 26-50 of 100."

    I think the Sencha paging grid example is pretty concise (http://www.sencha.com/examples/#ExamplePlace:paginggrid) and gives you everything you need to implement a paging grid.

    The key with the API is that it's powerful, flexible, and most importantly, reusable. You write your pagination code for your grid ONCE and it's reused for everything: sorting, pagination, and even filtering. And, the best thing is that the API takes care of all of that for you - you don't have to worry about populating any of the load config data.

Thread Participants: 1