[CLOSED] how to change the sort name when you are doing the sort by clicking the column header of gridpanel

  1. #1

    [CLOSED] how to change the sort name when you are doing the sort by clicking the column header of gridpanel

    Hi:

    I have a gridpanel which is bind with a store. The store will use HttpProxy which is get the data from controller. The store has a RecordField like:
    <ext:RecordField Name="ItemDescription" Mapping="Description">
    I have a column which is bind the data with the field above.

    When I click the header of the column, it automatically reload the data from controller, but the sort name it post to controller is "ItemDescription" which is the field name not the mapping name. I just wonder is there any place which I can set the sort name for the column or recordfield.

    Thank you
    Last edited by Daniil; Jul 25, 2011 at 5:56 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I'd suggest to override .load() of Ext.data.Store.

    Example

    <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    
    <script type="text/javascript">
        Ext.data.Store.override({
            load : function (options) {
                options = Ext.apply({}, options);
                this.storeOptions(options);
                if (this.sortInfo && this.remoteSort) {
                    var pn = this.paramNames;
                    options.params = Ext.apply({}, options.params);
                    //options.params[pn.sort] = this.sortInfo.field;
                    options.params[pn.sort] = this.fields.map[this.sortInfo.field].mapping;
                    options.params[pn.dir] = this.sortInfo.direction;
                }
                try {
                    return this.execute('read', null, options); // <-- null represents rs.  No rs for load actions.
                } catch (e) {
                    this.handleException(e);
                    return false;
                }
            }
        });
    </script>
    Another way can be passing mapping as a base parameter (BaseParams).
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    I'd suggest to override .load() of Ext.data.Store.

    Example

    <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    
    <script type="text/javascript">
        Ext.data.Store.override({
            load : function (options) {
                options = Ext.apply({}, options);
                this.storeOptions(options);
                if (this.sortInfo && this.remoteSort) {
                    var pn = this.paramNames;
                    options.params = Ext.apply({}, options.params);
                    //options.params[pn.sort] = this.sortInfo.field;
                    options.params[pn.sort] = this.fields.map[this.sortInfo.field].mapping;
                    options.params[pn.dir] = this.sortInfo.direction;
                }
                try {
                    return this.execute('read', null, options); // <-- null represents rs.  No rs for load actions.
                } catch (e) {
                    this.handleException(e);
                    return false;
                }
            }
        });
    </script>
    Another way can be passing mapping as a base parameter (BaseParams).
    Hi Daniil:

    Override .load() of Ext.data.Store will let the store always return the mapping field name. This is not suit for my case.
    I just wonder whether there is a way to define the sore name for each column header click.

    Thank you
  4. #4
    I forgot about "beforeload" event of Store.

    You can use it to change base params.
  5. #5
    Quote Originally Posted by Daniil View Post
    I forgot about "beforeload" event of Store.

    You can use it to change base params.
    Yes, that's work perfect now. Thank you

Similar Threads

  1. TreeGrid multi column sort
    By t316 in forum 1.x Help
    Replies: 4
    Last Post: Jul 19, 2011, 10:46 PM
  2. [CLOSED] Remove sort Asc/Desc from grid header context menu
    By jchau in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 29, 2009, 2:59 PM
  3. Sort with Conditional sort direction in JS- help!
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: May 05, 2009, 12:11 PM
  4. [CLOSED] Manually Set Grid Header Sort Icon
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 09, 2009, 12:22 PM
  5. Remove Sort Header
    By Kipetcoff in forum 1.x Help
    Replies: 2
    Last Post: Feb 15, 2009, 7:44 AM

Posting Permissions