How to change cell fore color on lost focus of the cell in WebGrid ?

3 replies. Last post: May 20, 2010 9:57 PM by Glenn Layaar
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Gaurav DesaiMember

We are using WebGrid 7.0 in SharePoint web part where we are rendering the web part programatically. 

We have inline editing enabled in our web grid where we are allowign users to enter  data. We want to change font color to (E.g. To RED) after cell editing is done and the focus is moved out of the cell being edited.

We have used the following JavaScript code for the same:

function WebUIGrid_OnExitEditMode(controlId, tblName, editObject) 
{
    editObject.cellElement.style.color = "red";
    return true;
}

But after this gets executed, the server side event "UpdateRow" gets executed and it changes the color back to the default color. So we tried to set the forecolor as Red with the following code written in  WebGrid_UpdateRow serverside event:

WebGridRow modifiedRow = e.Row;
            WebGridCellCollection cellCollection = modifiedRow.Cells;
            for(int cellCount = 0; cellCount < cellCollection.Count; cellCount++)
            {
                if (cellCollection[cellCount].DataChanged)
                    cellCollection[cellCount].Style.ForeColor = Color.Red;
            }

But the problem with this approach is that if we change Cell 6, moves the focus out of this row, this code gets executed and cell 6 becomes red in color. Next (Before saving the values) if we change Cell 7 of the same row then we will find only Cell 7 in red and Cell 6 gets the default fore color.

Any help on this would be greatly appreciable.

Thanks.

All times are GMT -5. The time now is 10:40 PM.
Previous Next