Selective EditMode

Is there a way to selectively enable editing on a grid cell? For example, if I have a column named "Price", with dollar values, and another column named "Editable", with true/false values, can I have the grid show the "Price" value in editable or non-editable mode based on the "Editable" value?

I tried doing this with a Blazor @if/else construction on the row as a whole, and also on just the edit template, but neither were successful.

I can control actual editability through logic in the underlying data class, but the non-editable values still mistakenly display as if they were editable.

Hi @bmccord

Not sure if I'm fully understanding what you're asking but I'll take a stab. Are you wanting to show Price column in both view and edit modes, but only allow editing of Price based on the value in another column?

If so, you can do all this in the Edit Template.

if(context.EditableTrueFalseColumn==true)
{
    // show a RadzenNumeric or RadzenTextBox for Price
}
else
{
    // just output a label
}

Regards

Paul

Thanks for the suggestion. This did the trick, although I'm not sure why it didn't work when I had it coded as

@if (condition)
{
EditTemplate A
}
else
{
EditTemplate B
}

It also didn't work when I had the if statement around the entire column. I'll have to revisit those and see if it was something else that was causing the problem. Thanks again.

1 Like