Replies
Maya,
Now I can get the active cell based on your sample code. Thanks!
Yes, I am using some template columns.
Now, I'd like to change the value of the cell. In my column I have a button and it's enabled property is tied to the value of the cell, a boolean. This seems to work fine to enable and disable the button.
However, in the javascript code when I try to set the value of the cell, the button disappears and the value in the database never gets updated. The text then says 'false' in the cell.
How can I set the value of a cell when using templates?
Thanks,
Brian.
Maya,
OK, so now I can access the gridView, thanks!
However, I'm not able to get the cell of the button I just clicked on.
In the behaviors of the grid I have the Activation turned on and the Selection turned on.
When I click on the button the whole row is selected, the client side javascript is called.
I am able to access the activation object when I call the get_activation(). However, if I then try to get the active cell via the code below, it is null.
var activeCell = grid.get_gridView().get_behaviors().get_activation().get_activeCell();
Is there something else I need to enable?
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…
GridRecordItem activated = e.Row.Items.FindItemByKey("Activated");
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.