:: Forum >> Version 1 >>

server-side sorting

Hi,

I'm planning to do server-side sorting. 2 questions:

1) How can I overide the default sort click event with my own function?

2) How can I manually set the style of the header column? Essentially I would like to make a request to the server to sort the data, retrieve the new results, recreate the table, and then set the ascending/descending image style where I want it.

Thank-you
Ron
Thursday, December 9, 2004
Not really sure if there is another solution, but I use:
/javascript.forum.2094.5/
Hope this helps
Carlos
Friday, December 10, 2004
I just made it this way... perhaps it should be made better by Active.HTTP.Request, but i do not know how to use it.... Maybe I'll make it later...

Redirecting sort function to a Server Side Script query
grid_obj.setAction("columnSort"
    function(
src)
    {
        var 
src.getItemProperty("index");
        var 
= (this.getSortProperty("index") == i) && (this.getSortProperty("direction")=="ascending""descending" "ascending";
        
window.status "Sorting...";
        
this.sort(src,id);
        
        
//this.refresh();
        
this.timeout(function(){window.status ""});
    });        
    
    
grid_obj.sort = function(src,indexdirection){
        var 
column src.getItemProperty("text");
        var 
model this.getModel("row");
        if (
model.sort) {
            return 
model.sort(indexdirection);
        }

        var 
= {};
        var 
rows this.getRowProperty("values");

         if (
direction && direction != "ascending" ) {
             
direction "descending";
         }
         else {
             
direction "ascending";
         }


        
/*if (this.getSortProperty("index") != index) 
        {
            for (var i=0; i<rows.length; i++) 
            {
                a[rows[i]] = this.getDataProperty("value", rows[i], index).toLowerCase();
            }
            rows.sort(function(x,y){return a[x] > a[y] ? 1 : (a[x] == a[y] ? 0 : -1)});
            if (direction == "descending") 
            {
                rows.reverse();
            }
        }
        else if (this.getSortProperty("direction") != direction) {
            rows.reverse();
        }*/
        
        
window.grid_data.location.replace("grid_data.php?fields=*&table=ad&order="+column+" "+(direction=="ascending" "ASC" "DESC"));

        
this.setRowProperty("values"rows);
        
this.setSortProperty("index"index);
        
this.setSortProperty("direction"direction);
        
    };
 
And it works fine for me... Should any one tell me how to make with Active.HTTP.Request instead of window.location.replace() ?
Saturday, December 11, 2004
Thanks for the responses.

The last two lines are exactly what I needed. I have a newbie question.
Where is the setSortProperty function defined? I can't find where it's defined in the source code. I'm assuming it's dynamically created somehow. Can somebody please explain to me how the function definitions are created?

Thanks again!
Ron
Tuesday, December 14, 2004



This topic is archived.

Back to support forum

Forum search