Hi,
I have got a UltraWebGrid in my web page, and I have a client side event - "BeforeExitEditModeHandler". I put some validation-related code in the client side function:
function UltraWebGrid1_BeforeExitEditMode(gridName, cellId, newValue) {};
The problem is: if it returns 0, then I am able to set the background color of the cell by doing cell.Element.style.backgroundColor = "#FF0000". However I can not set the background color of the cell if the function returns 1. In other words, the following code does not work:
cell.Element.style.borderColor = "#FF0000";return 0;
Anyone can help me out??
Many thanks
Regards,
Xiaosu
Hello,
If you return true (well, 1 in your case) the exiting of the edit mode is canceled and you still see the editor above the cell. The background color is changed but you can't see it because of the editor. Why do you need to return anything? Simply let it quit.
Hi Alex,
Thank you for your response. Actually, what I want to do is to change the background color if the value in the cell is invalid, and return 0. (Do not exit the editing mode, so that the user can continue to edit.)
I did the validation stuff in the client side function, so I validate the user input before exiting the editing mode. I can not show a different background color because there is a edtior in the cell. So how can I implement this?
Thanks a lot.
Is this the built-in editor you're using? The HTML element of it can be found as document.getElementById(gridName+"_tb"). Then you can change its style to indicate incorrect values. Don't forget to change it back to normal or otherwise it'll open with red background for the next cell as well.
Thank you for your help. It works nicely.
Thanks again.
Thank you for your response. But I do not quite get what you mean. What I did is:
function BeforeExitEditMode(gridName, cellId, newValue) {
var textbox = document.getElementById(gridName + "_tb"); textbox.style.backgroundColor = "#FF0000"; return 1;
}
The code above does not work. My question is: how can I get the HTML element ID of the editor in this cell (cell ID is cellId)?
Thank you very much for your help.