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

Attempting to make a cell enabled or disabled

1 Answer 13 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 04 Oct 2016, 10:12 AM

I have a grid which displays a field called "Import Type". There are various options under the Import Type based on a pre-defined enum model. One of the ImportType options is "Custom". If the user selects a Custom option, then another column next to it, "Mapping" needs to be enabled and mandatory. If the user selects any other ImportType, then "Mapping" needs to be blank and disabled. That is, if ImportType = "Custom" then Mapping is a mandatory cell for that particular row. If ImportType != "Custom" then Mapping should be disabled and blank. This ideally needs to be realtime during edit mode. So if the user clicks Edit and makes changes, this needs to be reflected instantly.

 

I'm struggling to get this working at all, mainly as I'm not sure what I'm doing it. Here is my code for the column so far.

columns.Bound(c => c.ImportType).Title("Import Type");
    columns.Bound(c => c.Mapping).Title("Mapping")     
    .ClientTemplate(
             "# if(ImportType== Models.CommonEnums.ImportType.Custom) #" +
             "# { return MappingId.HasValue === true} #" +
             "# else {MappingId = ''} #"
             );

Should I be using a Client Template? I have tried a few other things, using just .Template, however this didn't do much for me either.

 

Could you point me in the right direction?

 

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 07 Oct 2016, 10:30 AM
Hi Jon,

As I understand your requirement, you would like to make a cell in the Grid read-only if a condition is not met. In order to implement the behavior you can handle the Edit event of the Grid and check what is the value in the other field. Based on that, you can cancel the event and prevent the cell from being edited.

Please examine the following thread that discusses similar functionality.




Regards,
Viktor Tachev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or