Hi,First off, i'm working with ASP.Net 2.0 WebDataGrid Version 9.1.20091.2087I am trying to programmatically assign a javascript function to the ColumnSorted and DataFiltered events when the webdatagrid is initialised, the problem is that it never gets called when I sort or filter the grid in the browser. Below is my code.
function addWebDataGrid(grid, args) { var ev = grid.get_behaviors().getBehaviorByName('Sorting').get_events(); ev.addHandler('ColumnSorting', showSomething); ev.addHandler('ColumnSorted', hideSomething); //Is not firing ev = grid.get_behaviors().getBehaviorByName('Filtering').get_events(); ev.addHandler('DataFiltering', showSomething); ev.addHandler('DataFiltered', hideSomething); //Is not firing}
ev = grid.get_behaviors().getBehaviorByName('Filtering').get_events(); ev.addHandler('DataFiltering', showSomething); ev.addHandler('DataFiltered', hideSomething); //Is not firing}
As you can see I also want to handle the ColumnSorting and DataFiltering events, which work perfectly and as expected.Also note that I have tried manually adding the "hideSomething" function to the ColumnSorted and DataFiltered properties in the Visual Studio designer and they work as expected, its just programmatically adding the events that is not working.
Am I doing anything wrong?
Thanks for the reply Alex,
I have added a client side init function for to grid to call when it initialises. This init function adds the ColumnSorted event to the grid in javascript.
The problem isn't with the function itself, when I add the function to the ColumnSorted event in the Behaviors Designer everything works fine. Its when I add the ColumnSorted event to the grid in javascript, thats when it fails to fire.
function initWebDataGrid(grid, args) { if (grid.get_behaviors().getBehaviorByName('Sorting')) { var ev = grid.get_behaviors().getBehaviorByName('Sorting').get_events(); ev.addHandler('ColumnSorting', showLoading); ev.addHandler('ColumnSorted', hideLoading); }
if (grid.get_behaviors().getBehaviorByName('Filtering')) { ev = grid.get_behaviors().getBehaviorByName('Filtering').get_events(); ev.addHandler('DataFiltered', hideLoading); ev.addHandler('DataFiltering', showLoading); } }
Hello,
At which point is the this method being invoked? Probably the events are already fired when the grid reloads and this method is called after the fact.