Attempting to make a cell enabled or disabled

2 posts, 0 answers
  1. Jon
    Jon avatar
    4 posts
    Member since:
    Sep 2016

    Posted 04 Oct Link to this post

    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?

     

     

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 07 Oct Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top