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

CustomEditing(DropDown) Problem..

1 Answer 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 30 Jul 2013, 05:07 AM
When I am trying to edit or add in grid using Custom Dropdown Binding... in the code behind the viewmodel is not binding properly. It shows Id as Null and Name as Collection.
Could any one please solve this problem?
Thanks in Adv.
My View Model:
public class CategoryViewModel
  {
 
      public int? CategoryId { get; set; }
      public string  CategoryName { get; set; }
 
  }
My Editor Template
@model ViewModel.Query.CategoryViewModel
 
@(
    Html.Kendo().DropDownListFor(m => m)
        .DataTextField("CategoryName")
        .DataValueField("CategoryId")
        .BindTo((System.Collections.IEnumerable)ViewData["categories"])
 
)
My Grid Binding
@(Html.Kendo().Grid<TestCategoryQueryModel>()
                      .Name("Grid")
                      .Columns(columns =>
                          {
                              columns.Bound(p => p.Id);
                              columns.Bound(p => p.CatName);
 
                              columns.Bound(p => p.CatDescription).Filterable(false);
                              columns.Bound(p => p.CatImg).Filterable(false);
                              columns.Bound(p => p.Categories).Filterable(false);
                              columns.Bound(p => p.CatPublish).Filterable(false);
                              columns.Bound(p => p.CatShowOrder).Filterable(false);
                              columns.Bound(p => p.CatSubjectToAcl).Filterable(false);
                              columns.Bound(p => p.CatSearchKeys).Filterable(false);
                              columns.Command(c =>
                                  {
                                      c.Edit();
                                      c.Destroy();
                                  });
                          })
                      .ToolBar(tools =>
                          {
                              tools.Create();
                          })
                      .Sortable()
                      .Editable(editable => editable.Mode(GridEditMode.InLine))
                      .Pageable(pageable =>
                          {
                              pageable.Refresh(true);
                              pageable.PageSizes(true);
                          })
                      .Filterable()
                      .Groupable()
                      .ColumnMenu()
                      .DataSource(dataSource => dataSource
                                                    .Ajax()
                                                    .Model(model =>
                                                        {
                                                            model.Id(p => p.Id);
                                                            model.Field(p => p.Categories).DefaultValue(ViewData["defaultCategory"] as CategoryViewModel);
                                                        })
                                                    .Events(events=>events.Error("error_handler"))
                                                    .Read(read => read.Url("/api/TestCategoryWebApi").Type(HttpVerbs.Get))
                                                    .Create(create => create.Url("/api/TestCategoryWebApi").Type(HttpVerbs.Post))
                                                    .Update(update => update.Url("/api/TestCategoryWebApi").Type(HttpVerbs.Put))
                                                    .Destroy(destroy => destroy.Url("/api/TestCategoryWebApi").Type(HttpVerbs.Delete))
                      ))
When I am trying to edit, the datasource in Json Format
({$id:"2", Id:1, CatName:"Category Name1", CatDescription:"Test Description1", CatImg:"Image1", CatParentId:1, CatSubjectToAcl:false, CatSearchKeys:"Test 1", CatPublish:true, CatShowOrder:1, Categories:{CategoryId:3, CategoryName:"Category Name11"}})
and in the code behind(Web APi)when I trying to capture in the model it shows like this(Plz check the attachment)
 

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 01 Aug 2013, 06:17 AM
Hi Jay,

 
I tried to reproduce the problem locally but to no avail – everything is working as expected on our side. Could you please provide runable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Jay
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or