Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:31:05+00:00 2026-06-12T00:31:05+00:00

I currently have the code below that overrides the sort for all stores. What

  • 0

I currently have the code below that overrides the sort for all stores. What I need to do is create a sort for an individual store. How do I do that?

Ext.override(Ext.data.Store, {
    // override
    createSortFunction: function (field, direction) {
        direction = direction || "ASC";
        var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1;
        var sortType = this.fields.get(field).sortType;

        //create a comparison function. Takes 2 records, returns 1 if record 1 is greater,
        //-1 if record 2 is greater or 0 if they are equal
        return function (r1, r2) {

            var v1;
            var v2;

            if (field == 'Registered') {
                v1 = sortType(r1.data['AircraftNeedsRegistered']);
                v2 = sortType(r2.data['AircraftNeedsRegistered']);

                if (r1.data['AircraftNeedsRegistered'])
                    r1.data['Register'] = !r1.data['Register'];

                if (r2.data['AircraftNeedsRegistered'])
                    r2.data['Register'] = !r2.data['Register'];

                //store.getAt(rowIndex).data['Registered'] = true;
            }
            else {
                v1 = sortType(r1.data[field]);
                v2 = sortType(r2.data[field]);
            }

            // To perform case insensitive sort
            if (v1.toLowerCase) {
                v1 = v1.toLowerCase();
                v2 = v2.toLowerCase();
            }

            return directionModifier * (v1 > v2 ? 1 : (v1 < v2 ? -1 : 0));
        };
    }

What I want to implement is something like this:

function AircraftStore() {
return new Ext.data.JsonStore(Ext.apply({
    url: AVRMS.ROOT_CONTEXT + "/ssl/json/general/GetAircraftByOwnerId.aspx",
    idProperty: 'OwnerOid',
    baseParams: { OwnerOid: 0 },
    fields: ['AircraftOid', 'NNumber', 'Make', 'Model', 'Seats', 'RegistrationType', 'Airworthy', 'IsFaaAirport', 'AirworthyString', 'IsFaaAirportString', 'Airport', 'AircraftNeedsRegistered', 'Register'],
    sort: function (field, direction) {
        return customSort(field, direction);
    }
}));
    };

function customSort(field,direction) {
    //What do I put here?
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:31:06+00:00Added an answer on June 12, 2026 at 12:31 am

    I am not sure if I understood the purpose of your code correctly but I believe the same effect can be achieved by using the following code (sorry, I haven’t tested it but it should work).

    AircraftStore = Ext.extend(Ext.data.JsonStore, {
        url: AVRMS.ROOT_CONTEXT + "/ssl/json/general/GetAircraftByOwnerId.aspx",
        idProperty: 'OwnerOid',
        baseParams: { 
            OwnerOid: 0 
        },
        fields: ['AircraftOid', 'NNumber', 'Make', 'Model', 'Seats', 'RegistrationType', 'Airworthy', 'IsFaaAirport', 'AirworthyString', 'IsFaaAirportString', 'Airport', 'AircraftNeedsRegistered', 'Register'],
        sort: function (field, direction) {
            if (field == 'Registered') {
                field = 'AircraftNeedsRegistered';
                this.query('AircraftNeedsRegistered', true).each(function(record) {
                    record.data['Register'] = !record.data['Register'];
                });         
            }
            return AircraftStore.superclass.sort.call(this, field, direction);
        }
    });
    

    If this does not achieve your desired behaviour because I missed something, you can just override the createSortFunction instead of sort. However, since createSortFunction is supposed to be private, it is better to handle custom logic by overriding sort. Anyway, if you prefer to stay with your first approach, your AircraftStore should look like this:

    AircraftStore = Ext.extend(Ext.data.JsonStore, {
        url: AVRMS.ROOT_CONTEXT + "/ssl/json/general/GetAircraftByOwnerId.aspx",
        idProperty: 'OwnerOid',
        baseParams: { 
            OwnerOid: 0 
        },
        fields: ['AircraftOid', 'NNumber', 'Make', 'Model', 'Seats', 'RegistrationType', 'Airworthy', 'IsFaaAirport', 'AirworthyString', 'IsFaaAirportString', 'Airport', 'AircraftNeedsRegistered', 'Register'],
        createSortFunction: function (field, direction) {
            // copy your createSortFunction here
        };
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a borderContainer layout as shown below: My code for this layout
I have a python psp page code is shown below. Currently it only prints
I currently have code that does the following: private final static ExecutorService pool =
I currently have code in objective C that can pull out an integer's most
I currently have this code which stores XML into an XML-type column called data,
I have two relative layouts that are currently displayed one below the other. I
I currently have the code below it works fine up until I actually try
The code below is what I currently have, however it overwrites any data in
Using dotnet 2.0. I currently have code like this : DataView dv = new
I currently have this code: PACKETS = {}; function AddPacket(data) local id = data.ID;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.