3.2.0

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
December 9,
Not really sure if there is another solution, but I use:
http://www.activewidgets.com/messages/2094-5.htm
Hope this helps
Carlos
December 10,
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 i = src.getItemProperty("index");
        var d = (this.getSortProperty("index") == i) && (this.getSortProperty("direction")=="ascending") ? "descending" : "ascending";
        window.status = "Sorting...";
        this.sort(src,i, d);
        
        //this.refresh();
        this.timeout(function(){window.status = ""});
    });		
    
    
grid_obj.sort = function(src,index, direction){
        var column = src.getItemProperty("text");
        var model = this.getModel("row");
        if (model.sort) {
            return model.sort(index, direction);
        }

        var a = {};
        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() ?
December 11,
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
December 14,

This topic is archived.

See also:


Back to support forum