This is a migrated thread and some comments may be shown as answers.

Disable cell edit for a specific column

1 Answer 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gustavo
Top achievements
Rank 1
Gustavo asked on 01 Dec 2014, 12:29 PM
Hi,

I have a Batch Edit Grid and I'm trying to make a column read only in edit mode with the code below:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        TextBox txt = (TextBox)editedItem["RangeMin"].Controls[0];
        txt.ReadOnly = true;
    }
}

But the expression if (e.Item is GridEditableItem && e.Item.IsInEditMode) always return false.

How can I disable cell edit for a specific column?

Thanks,
Gustavo

1 Answer, 1 is accepted

Sort by
0
Gustavo
Top achievements
Rank 1
answered on 01 Dec 2014, 03:47 PM
I solved my problem with this code:

<ClientSettings>
  <ClientEvents OnBatchEditOpening="OnBatchEditOpening" />
</ClientSettings>
  
function OnBatchEditOpening(sender, args) {
  if (args.get_columnUniqueName() == "RangeMin")
    args.set_cancel(true);
}

Thanks
Tags
Grid
Asked by
Gustavo
Top achievements
Rank 1
Answers by
Gustavo
Top achievements
Rank 1
Share this question
or