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

grid sorting-filtering and editing

1 Answer 47 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Michael asked on 25 Dec 2017, 12:16 PM


I have a property stakeHolder he is an object type of Developer.

In my grid I want to add a product but the field stakeHolder is editable(false) and i put on it the name I want hard coded.

The problem is if I use stakeHolder.Name then sorting and filtering work good but when i trying to add row then an error occurred " StakeHolder is not defined"

and when I use stakeHolder then everything is working great except for sorting and filtering (as I know filtering/sorting don't work on object)

what can I do?

namespace TaskManagementUI.Models
    public class Developer
        public int? ID { get; set; }
        [Required(ErrorMessage = "Please enter a name")]
        [Display(Name = "Name")]
        public string Name { get; set; }

          .Columns(columns =>
              columns.Bound(c => c.ID).Hidden();
              columns.Bound(c => c.Name).Title("Name").Width(200);
              columns.Bound(c => c.CreateDate).Title("Creation date").Format("{0: MM/dd/yyyy}").Width(200);
              columns.Bound(c => c.Description).Title("Description").Width(250);
              columns.Command(command => command.Custom("ADDPROJECT").Text("Add Project").Click("addProject")).Title("Add Project").Width(170).HtmlAttributes(new { id = "addProjectButton" });
              columns.Command(command => { command.Edit().UpdateText("SAVE"); command.Destroy(); }).Width(250);


            .Resizable(resize => resize.Columns(true))
           .ToolBar(toolbar =>
               toolbar.Create().Text("Add New Product");
            .Editable(editable => editable.Mode(GridEditMode.InLine).TemplateName(""))
           .Excel(excel => excel
                          .ProxyURL(Url.Action("FileExportSave", "Home")))
          .Pageable(pager => pager
                            .PageSizes(new int[] { 6, 15, 20 })
          .Sortable(sortable =>
          .DataSource(dataSource => dataSource
                                   .Events(events => events.Error("errorHandlerProduct"))
                                  .Model(model =>
                                      model.Id(item => item.ID);
                                      model.Field(a => a.StakeHolder.Name).DefaultValue(new Developer {ID=52,Name="Uriel Ash"}).Editable(false);
                                      model.Field(a => a.CreateDate).Editable(false);
                                   .Read(read => read.Action("GetSavedProducts", "Product"))
                                   .Update(update => update.Action("UpdateProduct", "Product"))
                                   .Destroy(update => update.Action("DeleteProduct", "Product"))
                                   .Create(update => update.Action("CreateProduct", "Product"))))

1 Answer, 1 is accepted

Sort by
Alex Hajigeorgieva
Telerik team
answered on 26 Dec 2017, 01:57 PM
Hello, Michael,

The observed behaviour is due to a default value missing for the complex object field StakeHolder.

You can supply it in the Kendo UI Data Source model definition, for example:

.DataSource(dataSource => dataSource
  m.Field(f => f.StakeHolder).DefaultValue(new Developer() { ID = 0, Name = "Default" });

Let me know if you need further help.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question