Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Steve Boulay on Nov 17, 2009 01:07
open dhtmlx forum
multi grid and events

Hello,

In my page, i use two grids. When a event is sent on a grid, i don't know in which grid i am. When i'm in a function attached on custom sorting i don't know which grid is sorting. I can't imagine, i must write a function for each grid.

Thanks
Answer posted by Stanislav (support) on Nov 17, 2009 01:45
Inside event handler, "this" always points to the grid object, for which event was called

mygrid.attachEvent("onEditCell",function(){
      // this == mygrid
})
Answer posted by Steve Boulay on Nov 17, 2009 01:54
But it's not true in a function of custom sorting. How can i know in which grid i'm in this case?

Thanks
Answer posted by Stanislav (support) on Nov 17, 2009 06:20
There is no way to detect such info in case of custom sorting. 
If you really need it , then 

var currentGrid=null;
var setGrid = function(){ currentGrid = this; return true; }
mygrid1.attachEvent("onBeforeSorting",setGrid)
mygrid2.attachEvent("onBeforeSorting",setGrid)

now, inside custom sorting method you will be able to access currentGrid variable.