Pergunta

My grid looks like this.

Key Value
1    A
2    B
3    C

I have Value column read-only in my grid. "Value" column's columnedit is associated with memoexedit repository. Now what I want to do is on some condition like when key=2, I want my value cell to be editable.

I tried making the whole column ReadOnly = false.

and then handled ShowingEditor to cancel edit on everything else than Key=2, but that prevents even opening up the editor for other values.

What I want is able to see the editor but it should be readonly for Others and for Key=2, It should be editable.

Please help!

Foi útil?

Solução

Try to handle the ShownEditor event as the following (semi-pseudo code):

var grid = sender as GridView;
if (grid.FocusedColumn.FieldName == "Value") {
    var row = grid.GetRow(grid.FocusedRowHandle) as // your model;
    // note that previous line should be different in case of for example a DataTable datasource
    grid.ActiveEditor.Properties.ReadOnly = // your condition based on the current row object
}

This way you could refine the already opened editor with your needs.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top