Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Martin on Apr 15, 2009 09:07
open dhtmlx forum
Grid Sorting (Smart Rendering)

Hello,

I have attached a function "sortGridOnServer" as "onBeforeSorting"-event. Like you say in the tutorial I pass three parameters to the function: ind, gridObj, direct. Now the problem is, that the direct parameter is undefined, so the sorting doesnt work.
Can you help me out here?

Thx in advance, Martin
Answer posted by dhxSupport on Apr 16, 2009 00:43

Sorry for the misleading information.There is a mistake in the documentation. "onBeforeSortin" handler should looks like that:

grid.attachEvent("onBeforeSorting",function(ind,type,direction){
  this.clearAll(); // clear grid
  this.loadXML("some.url?direction="+direction+"&ind="+ind); //load a new dataset from the server, with necessary order
  this.setSortImgState(true,ind,direction); //set a correct sorting image
  return false;  
  });


"direction" parameter in such case is a direction of a sorting ("des" or "asc")

Note, that code will not sort grid on your server side. You should adjust your server side code that it will return rows in the necessary direction. 

Answer posted by Martin on Apr 16, 2009 04:15
Hmmm ... doesnt work. When I alert the "direction"-parameter within the function it still says "undefined".