Are there any good sample snippets of how to use the MouseOver client-side event of the WebDataGrid?
My problem is I am trying to gain access to the row being hovered over and do some action based on that. how do I gain access to the row being hovered over?
On another note, what tool can i use to see the sender and eventArgs properties/methods available. You never realize how much you need intellisense until it's not there!?
Sample code for other Mouse events would help too... Thanks.
I am writing same method what you have written & getting "Microsoft Jscript runtime error : Object does not support property or method 'get_element'
Hi Scott,
Sorry for the MouseOut issue.
Looks like the cells background is covering the row background so you need to set the desired background-color to every cell.
Have a look at this code.
function setRowCellsBackgroundColor(row, backgroundColor) {
var cellCount = row.get_cellCount();
for(var i = 0; i < cellCount; i++) {
row.get_cell(i).get_element().style.backgroundColor = backgroundColor;
}
function WebDataGrid1_Grid_MouseOver(sender, eventArgs) {
if (eventArgs.get_type() == "cell") {
eventArgs.get_item().get_row().get_element().style.fontWeight = "bold";
setRowCellsBackgroundColor(eventArgs.get_item().get_row(), "Yellow");
eventArgs.get_item().get_row().get_element().style.color = "Red";
else if (eventArgs.get_type() == "row") {
eventArgs.get_item().get_element().style.fontWeight = "bold";
setRowCellsBackgroundColor(eventArgs.get_item(), "Yellow");
eventArgs.get_item().get_element().style.color = "Red";
function WebDataGrid1_Grid_MouseOut(sender, eventArgs) {
eventArgs.get_item().get_row().get_element().style.fontWeight = "normal";
setRowCellsBackgroundColor(eventArgs.get_item().get_row(), "");
eventArgs.get_item().get_row().get_element().style.color = "";
Thanks
I managed to find a workaround for the MouseOut issue... but now I'm trying to change the backgroundColor of the row and it does nothing, why is this happening?? Is there something overriding the backgroundColor. The font color and bold change is working as expected. See code below:
eventArgs.get_item().get_row().get_element().style.backgroundColor = "Yellow";
eventArgs.get_item().get_element().style.backgroundColor = "Yellow";
eventArgs.get_item().get_row().get_element().style.backgroundColor = "";
Well... it's seems I had a typo, it helps if we use get_item() and not get_type(), as soon as I changed it to get_item(), the line of code below in MouseOver worked perfectly.... however.... Now my MouseOut event is only firing for Header and Cell MouseOut events, no Row MouseOut events are registering... why would this occur?
You should look at the documentation to find out what properties/methods are available.
Of course as much as we try to document everything there are some things that you can only find by debugging the code.
This can be easily done either with Visual Studio which has good javascript debugger or with the developer tools that are present in almost every browser.
To try out the visual studio debugger write "debugger;" in the javascript code and run the application in debug mode and it should break at that statement. All the visual studio debugging features like "Quick Watch" will be available and you can explore the objects that way.
Check this blog post for more information.
About your last question.
The "get_element()" method returns the actual html dom element so you should use its "style" property.
function WebDataGrid1_Grid_MouseOver(sender, eventArgs){ if (eventArgs.get_type() == "row") { eventArgs.get_type().get_element().style.fontWeight = "bold"; }}
Hope this helps