DropdownList in Grid Not preserving the previous value on Edit

2 posts, 0 answers
  1. Tim
    Tim avatar
    5 posts
    Member since:
    Mar 2015

    Posted 12 Jun 2015 Link to this post

    Hi All,

    Struggling with a very peculiar problem.

    I have a Kendo grid with kendo dropdownlist in some of the columns. The dropdown is populated based on values from in the database.

    Problem:

    On Edit in grid, the dropdown is not preserving previous saved value. 

    Please can you help me in finding  the solution for the problem.

    VIEW Code:

     @(Html.Kendo().Grid<ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel>(Model)
        .Name("gridTable")    
        .HtmlAttributes(new { style = "font-family: verdana,arial,sans-serif; font-size: 11px;color: #333333;border-color: #999999;" })
        .Columns(columns =>
        {
            columns.Bound(p => p.ClientAppName).ClientTemplate("# try {# #=ClientAppName# #} catch (e) {}#").EditorTemplateName("ClientComboBoxLookup").Width(120).Filterable(ft => ft.UI("ClientApplicationsFilter"));
          
            columns.Bound(p => p.SupplierAppName).ClientTemplate("# try {# #=SupplierAppName# #} catch (e) {}#").EditorTemplateName("SupplierComboBoxLookup").Width(120).Filterable(ft => ft.UI("SupplierApplicationsFilter"));
          
            columns.Bound(p => p.ListName).ClientTemplate("# try {# #=ListName# #} catch (e) {}#").EditorTemplateName("MasterDataListsComboBoxLookup").Width(150).Filterable(ft => ft.UI("ListsFilter"));
            columns.Bound(p => p.ClientValueName).Width(120).Title("Client Value");
            columns.Bound(p => p.ClientValueDescription).Width(200);
            columns.Bound(p => p.ClientCodingSystem).Width(150);
            columns.Bound(p => p.SupplierValueName).Width(120).Title("Supplier Value"); ;
            columns.Bound(p => p.SupplierValueDescription).Width(200);
            columns.Bound(p => p.SupplierCodingSystem).Width(150);
            columns.Bound(p => p.Direction).Width(90).ClientTemplate("# try {# #=Direction# #} catch (e) {}#").EditorTemplateName("DirectionComboBoxLookup").Filterable(ft => ft.UI("DirectionsFilter"));
            columns.Command(command =>  {
                    command.Edit();
                    command.Destroy();
                }).Width(200);
           
        })
                .ToolBar(t => t.Create())
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Filterable(e => e.Extra(false))
                .Pageable(page => page.PageSizes(new int[] { 10, 25, 50, 100 }).Enabled(true))
                .Sortable()
                .Scrollable(src => src.Height("auto"))
                .Resizable(resize => resize.Columns(true))
                .DataSource(
                    source => source
                        .Ajax() 
                        .Events(events => events.Error("error_handler"))                    
                        .ServerOperation(true)                  
                        .Model(model =>
                    {
                        model.Id(e => e.MasterDataMappingId);
                        model.Field(e => e.MasterDataMappingId).Editable(false);
                        //model.Field(p => p.ClientAppName).Editable(true).DefaultValue(ViewData["defaultApplications"] as ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel);
                        //model.Field(p => p.SupplierAppName).Editable(true).DefaultValue(ViewData["defaultApplications"] as ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel);
                        //model.Field(p => p.ListName).Editable(true).DefaultValue(ViewData["defaultMasterDataList"] as ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel);
                        
                    })                
                    .Create(create => create.Action("Create_MasterDataMapping", "Home"))
                    .Read(read => read.Action("Read_MasterDataMapping", "Home"))
                     .Update(update => update.Action("Update_MasterDataMapping", "Home"))
                     .Destroy(destroy => destroy.Action("Destroy_MasterDataMapping", "Home")))
                     //.Events(e => e.Edit("onEdit"))
                )

     Editor Template:

    @(Html.Kendo().DropDownListFor(m => m)
            .Name("ClientAppName")
            .DataValueField("AppId")
            .DataTextField("ApplicationName")
            .BindTo((System.Collections.IEnumerable)ViewData["Applications"])
            .AutoBind(false)        
            .Events(e =>
            {
                e.Select("onSelect");
            })
    )

  2. Tim
    Tim avatar
    5 posts
    Member since:
    Mar 2015

    Posted 15 Jun 2015 Link to this post

    Hi All,

    Need your help for the above post.

    I am not sure where I am going wrong. Highly Appreciate any help.

    Cheers

    Dino

Back to Top