I'd like to change what the user sees in the grid. Let's say I have a boolean column that is showing 'true' or 'false' and I'd like to show 'Yes' or 'No' instead.
I seem to be able to accomplish this somewhat by placing some code in the InitializeRow event.
Like...
GridRecordItem activated = e.Row.Items.FindItemByKey("Activated");
if (activated != null)
{
if ((bool)activated.Value == false)
activated.Text = "No";
if ((bool)activated.Value == true)
activated.Text = "Yes";
}
This seems to work, however if I edit a different value in the row and move to another row the formatting on the 'Yes/No' reverts back to 'true/false'.
So, it seems that after a row has been updated I need to reapply the formatting.
Where is the appropriate place to format the display value of a cell?
Thanks,
Brian.
Well, not exactly what I was looking for. However, I did stumble across a solution.
Each column has a FormatFieldMethod. So, for the true/false to Yes/No conversion, you can define a conversion method like...
private string FormatTrueFalseToYesNo(ControlDataField field, object value)
if (value is Boolean)
Boolean trueFalse = (Boolean)value;
if (trueFalse == true)
return "Yes";
if (trueFalse == false)
return "No";
return "Error";
Then in the Initialize row event I do...
if (activated != null && activated.Column.FormatFieldMethod == null)
activated.Column.FormatFieldMethod = new FormatRecordItemValue(FormatTrueFalseToYesNo);
Now all of the true / false fields say Yes or No and this stays updated when I edit other cells in a row and move to other rows.
This is not a solution if you want to be able to type in Yes or No, this is only a solution to display a different text in a cell.
Hello Brian,
Look at the following forum thread and let me know if this is the functionality that you require - http://community.infragistics.com/forums/p/57603/293756.aspx#293756