Hi,
I would like to change the background color of a cell when its values is changed. Can anybody please help me.
Thanks in Advance.
Bhaskar.
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
You can handle Exiting edit mode event and change the background color there. Something like this:
function WebDataGrid1_CellEditing_ExitingEditMode(sender, eventArgs)
{
eventArgs.getCell().get_element().style.backgroundColor = "red";
}
Hope this helps.
Regards,
Lyuba
Developer Support Engineer
Infragistics
www.infragistics.com/support
Is there a way in the javascript function to determine if the value actually changed at all? This solution changes the background color of any cell that's been put to edit mode, regardless of whether the value actually changed.
Basically, is there a "dirty" flag in cell editing client-side events? I'm having a real hard time finding API information for the client-side events.
You can also use the
_Editing_CellValueChanged
event. This only fires when the value changes.
FYI, for those curious, I ended up handling it myself by attaching OnEnter and OnExit client side events. OnEnter, I attach the "original" value via a jquery data entry on the cell's DOM element and OnExit, I read it and compare to it to the current value. If it's different, I add an appropriate CSS class.
A quick code snippet:
function onCellEnteringEditMode(sender, e) {
var cell, element;
if (!e) return;
cell = e.getCell();
if (!cell) return;
element = cell.get_element();
// capture the cell's origtinal value as original value data
$(element).data("originalValue", cell.get_value());
function onCellExitedEditMode(sender, e) {
var cell, element, origValue;
// make sure all inputs are proper and available
if (!element) return;
origValue = $(element).data("originalValue");
// if original value differs from the cell's current value, highlight it!
if (origValue !== cell.get_value()) {
$(element).addClass("grid-cell-edited");
// clean up original value data
$(element).removeData("originalValue");