Results 1 to 7 of 7

Thread: Grid sort: How to act on column sort before sort operation is performed

  1. #1
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Answers
    5

    Question Grid sort: How to act on column sort before sort operation is performed

    Hi,

    I have a query view where the results are displayed in a grid. The users have the options to save queries with the sort order. When the user loads a saved query, I set the store.proxy.extraParams to indicate the order to be used.
    However, when the user chooses to sort the data differently by clicking on the column headers, or by choosing sort order from the column header menu, I need to remove the saved order from the the extraParams.

    I tried to do this using the sortchange event, but I found that the sortchange event is fired only after the call to doSort(). I also tried to override onSortAscClick and onSortDescClick, but it did not work.

    Any ideas how to do this ?
    Yaron Yogev

    IT Software Developer

  2. #2
    Sencha User
    Join Date
    Oct 2010
    Location
    St.Petersburg
    Posts
    40
    Answers
    4

    Default

    Try to use grid store sorters instead of modifying of proxy extra params. Grid complitely clears store sorters each time user initiates any sorting operation. Personally, I prefer acting same way with grid filters.
    As for me, this practice is preferable because application logic (applying user dataview preset in your case) shouldn't know anything about databinding backend, proxys, datatransfer formats, package envelopes etc - all this crap has no matter for it.

    PHP Code:
    function applyPreset(presetstore) {
         
    store.sorters.clear();
         
    store.sorters.addAll(preset.getSorters());
         
    store.filters.clear();
         
    store.filters.addAll(preset.getFilters());
         
    store.load(); // for remote stores only

    Think less, write more.

  3. #3
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Answers
    5

    Default

    Hello Barzoy,

    Thanks for your answer. I did consider this, but my preset is not always using columns that are in the store. It gives a sort order which refers to fields that are not necessarily in the grid.

    I have to explain here that in my query view the user can select what columns to show, and there are dozens of possible columns, many of which require JOIN on external DB tables, so I cannot possibly have all the columns in the grid columns list all the time. I have a dialog window allowing the user to do the selection of columns.

    The question is this: if I want to convey the preset order through the sorter, can I put just any value in the sorters, as this grid uses a remote sort ?

    Thanks,
    Yaron Yogev

    IT Software Developer

  4. #4
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Answers
    5

    Default

    Another point to consider: when the user changes the sort order I keep the changed state.
    If I load a saved query, I want to use the preset order without modifying the state.
    Yaron Yogev

    IT Software Developer

  5. #5
    Sencha User
    Join Date
    Oct 2010
    Location
    St.Petersburg
    Posts
    40
    Answers
    4

    Default

    Does your serverside SQL expression depends on list of visible columns or set of joined tables always the same? If the set of joinedtables varies then you have to filter list of sorters with Ext.Array.filter before you pass them into the store.
    Think less, write more.

  6. #6
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Answers
    5

    Default

    The preset sorters can contain contain columns that are not not in the store currently. The back-end script knows the column definitions and can handle this properly. However, if I pass it via Array.filter than it will probably never get to the server, which defeats the purpose of this.

    I guess I'll just have to experiment with this and see if I can use the sorters to keep names of external properties (i.e. names which do not appear in the store's fields list).
    Yaron Yogev

    IT Software Developer

  7. #7
    Sencha Premium Member
    Join Date
    Jan 2008
    Location
    San Francisco Bay, CA
    Posts
    45
    Answers
    1

    Question beforesort ev is not documented and it doesn't stop sorting if handler returns false

    Hi, @slemmon
    Regarding http://docs.sencha.com/extjs/4.1.3/#...re-method-sort , the `beforesort` event is not documented and it doesn't stop sorting if the event handler returns false (as with `beforeload`).

    Should I file a bug?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •