[CLOSED] globalisation of the sort function

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] globalisation of the sort function

    Hi,

    your implementation of grid column sort, is it browser culture specific? or is the sorting based on the english culture.

    Regards
    Last edited by Daniil; Aug 02, 2011 at 1:58 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I'm not sure how sorting can be depend on a culture. Please clarify.

    I mean that:

    1 < 0 is false under any culture

    1 > 0 is true under any culture

    "aa" < "ab" is true under any culture

    Any date objects are compared by its .getTime() - it should give the same result under any culture.
  3. #3
    well, sorting order depends on culture. you can read this article to get more information about what I am talking about.
    http://msdn.microsoft.com/en-us/goglobal/bb688122.

    Could you verify from your developers if you do not know the answer to my original question.

    On the grid, sorting is performed when the column header is clicked. How can you provide a custom javascript sort handler for this action. Could you provide me with a sample code.


    regards
  4. #4
    Well, I meant client side sorting.

    By default there is client side sorting if you didn't set RemoteSort="true" for a Store.

    Client side paging means that sorting is done by JavaScript. Sorting by JavaScript doesn't depend on a culture.

    You can do sorting on server side. Here is done remote sorting.
    https://examples1.ext.net/#/GridPane...ilters_Remote/

    On the grid, sorting is performed when the column header is clicked. How can you provide a custom javascript sort handler for this action. Could you provide me with a sample code.
    Please follow
    http://forums.ext.net/showthread.php?12152
  5. #5
    How can I overide the client side sorting to provide my own javascript sorting function.?
    Please provide code sample
  6. #6
    Please clarify did you see that?
    Quote Originally Posted by Daniil View Post
  7. #7
    The sample in the link you provided will not help me in anyway. That sample is using sortType which will not help me in anyway as I want to do a string comparision. I am interested in performing a sorting similar to

    function localeSort(v1,v2) {
            var st1 = v1.data['name'], st2 = v2.data['name'];
            return(st1.localeCompare(st2));
        }
    I need to if poosible override the applySort() function of the store component or overrride the sort() function.

    So my question, is How does one override the applySort() of the Ext.net store component.

    Regards
  8. #8
    Please add this into <head> of a page.
    <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    
    <script type="text/javascript">
        Ext.net.Store.override({
            applySort : function () {
                //your code    
            }
        });
    </script>
  9. #9
    Hi ,

    How can I append/extend the recordField class? I want to add a handler called sortFuntion to the recordField class as shown below. How can that be achieved. This will enable me to add specific sort algorithm to my columns. The sortfuntion will have the signature "function MySortFunction(v1, v2)". I know that the recordfield have a CustomSortType, thats not what I am talking about as that will not help me in anyway.
    Can this be done the same way that the applySort function was overriden through javascript.

    Regards


     <ext:Store ID="Store1" runat="server">  
             <Reader>                   
                 <ext:ArrayReader>                    
                    <Fields>                           
                         <ext:RecordField Name="test1"  sortFuntion="MySortFunction"/>  
                        <ext:RecordField Name="test2" Type="String"/>                    
                        <ext:RecordField Name="test3" />          
                    </Fields>                   
                </ext:ArrayReader>   
            </Reader>    
            </ext:Store>
    below is the signature of my sort funtion
    function MySortFunction(v1, v2) {
        var st1 = v1.data['name'], st2 = v2.data['name'];
        return (st1.localeCompare(st2));
    }
  10. #10
    Not sure how you are going to use that "sortFunction".

    Anyway, you can just extend RecordField class:
    class MyRecordField : RecordField
    {
    
    }
    and add to the Reader's Fields:
    Store1.Reader[0].Fields.Add(new MyRecordField());
    I'd suggest you to use CustomSortType and override the Ext.data.Store's .createSortFunction() method.

    Here is the original .createSortFunction() method.
    createSortFunction : function (field, direction) {
        direction = direction || "ASC";
        var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1,
            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 = sortType(r1.data[field]),
                v2 = sortType(r2.data[field]);
    
            return directionModifier * (v1 > v2 ? 1 : (v1 < v2 ? -1 : 0));
        };
    }
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Sort in Panel?
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 06, 2012, 9:44 AM
  2. [CLOSED] combo sort
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 16
    Last Post: Jan 12, 2012, 7:29 PM
  3. Replies: 4
    Last Post: Jul 25, 2011, 4:57 PM
  4. [CLOSED] GridPanel and Sort
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 17, 2010, 8:12 AM
  5. 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

Tags for this Thread

Posting Permissions