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

[Solved] Make dropdown list readonly in Edit Mode

0 Answers 17 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Silviu
Top achievements
Rank 1
Silviu asked on 29 May 2012, 02:33 PM
Hello everybody,

I have a Telerik grid built like this:
 var customGrid = new ParticipantCoursGrid();
                    var grid = customGrid.GetBuilder(Html)
                       .HtmlAttributes(new Dictionary<string, object> { { "class", "expand" } })
                         .DataBinding(p => p.Ajax().Select("GetParticipants", "ParticipantCours", new { id_CRS = Model.id_CRS }))
                         .DataBinding(p => p.Ajax().Update("Edit", "ParticipantCours", new { idCRS_PCR = Model.id_CRS }))
                         .DataBinding(p => p.Ajax().Insert("Create", "ParticipantCours", new { idCRS_PCR = Model.id_CRS }))
                       .Name("ParticipantCours")
                       .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image))
                       .Columns(columns =>
                       {
                          
                           columns.Bound(type => type.NOM_PRENOM).Title(ViewRes.ParticipantCours.Index.NOM_PRENOM).EditorTemplateName("Personnel");

                           columns.Bound(type => type.NOM_RPC).Title(ViewRes.ParticipantCours.Index.NOM_RPC).EditorTemplateName("Rol");
                           columns.Bound(type => type.nom_CLC).Title(ViewRes.ParticipantCours.Index.nom_CLC).ReadOnly();
                           customGrid.Add_remarques_PCR_Column(columns);

                           columns.Command(command =>
                           {

                               command.EagleEditCommand();
                               command.EagleDeleteCommand();
                           }).IncludeInContextMenu(false);
                       })
                       .ClientEvents(e => e
                           .OnRowSelect("handleParticipantCoursGridRowSelect")
                           .OnRowDataBound("handleParticipantCoursGridRowDataBound")
                           .OnDataBound("handleParticipantCoursGridDataBound")
                           .OnDataBinding("handleParticipantCoursGridDataBinding")
                           .OnEdit("handleParticipantCoursGridEdit")
                       );

The first two columns are rendered using Razor like this:

@model dynamic

@Html.EagleDropDownList().Name("idRPC_PCR").DataBinding(data=>data.Ajax().Select("RolSelectList","Rol"))

and the same for the Personnel dropdown.

I would like to use Javascript to make them readonly in the OnEdit event when the mode is edit:

function handleParticipantCoursGridEdit(e) {

    

    if (e.mode == 'insert') {
//some code here
    }
else{
//mode is edit; add here the code to make the columns unaccesible.
}
    _defaulthandleParticipantCoursGridEdit();
}

Any suggestion is a step forward. Thank you in advance.
Tags
Grid
Asked by
Silviu
Top achievements
Rank 1
Share this question
or