0
votes

I have used kendo grid in my MVC project. In the my grid i have 3 columns e.g. city, state, country columns. These 3 columns in grid have combox to select value in the grid. But here i am facing an issue, for the first time when page is getting loaded, i am able to view combobox in the columns but after page refresh combobox are getting disappeared and replaced by textbox. Any suggestion would be helpful. For reference posting grid code.

@(Html.Kendo().Grid<ProjTest.Models.Test>()
        .Name("Test")
        .Columns(columns =>
        {
            foreach (System.Data.DataColumn column in Model.Columns)
            {
                var c = columns.Bound(column.ColumnName);
                c.Title(column.Caption);
                if ((column.DataType.Name) == "String") c.Filterable(ftb => ftb.Operators(o => o.ForString(s => { s.Clear(); s.IsEqualTo("Is equal to"); s.IsNotEqualTo("Is not equal to"); s.StartsWith("Starts with"); s.Contains("Contains"); s.DoesNotContain("Does not contain"); s.EndsWith("Ends with"); s.IsNotNull("Is not empty"); s.IsNull("Is empty"); })));

                switch (column.ColumnName)
                {
                    case "City":
                        c.EditorTemplateName("_City");
                        break;
                    case "State":
                        c.EditorTemplateName("_State");
                        break;
                    case "Country":
                        c.EditorTemplateName("_Country");
                        break;

                }
            }
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model =>
            {
                foreach (System.Data.DataColumn column in Model.Columns)
                {
                    var field = model.Field(column.ColumnName, column.DataType);
                }
            })
            .Action("Read", "Test")
            .Data("gridParam")
            )
    )
        .Events(events => events
        .DataBound("onDataBound")
        .Edit("onEdit")
    )     

)

1

1 Answers

0
votes

Make sure to call EditorTemplateName in 'onEdit' function i.e you need to re-create the templates on every edit. Please refer the documentation here