MVC Grid with Client Side functionality on Model Property

3 posts, 0 answers
  1. GCS
    GCS avatar
    20 posts
    Member since:
    Apr 2013

    Posted 08 Mar 2016 Link to this post


     I have a model defined as 

    public class Parent
            public List<Child> Children { get; set; }  

    public class Child
        property int Id { get; set;}
        property string Name {get; set;}
        property int  Age {get; set;}

    My goal is to have a grid on my main page whereas the model is the parent and the grid is used to populate the Children list. I do not want the grid to invoke any server method. It should just populate the  Children list. When the parent is saved, I am intending that its Children list will contain the items added within the Parent's POST operation. 

    I can create the grid, but I can't seem to get it to add items. When I add the toolBar.Create() option, I get the following error; 

    "The Insert data binding setting is required by the insert command. Please specify the Insert action or url in the DataBinding configuration."

    But I don't want any insert action to occur on the server. I just want the grid to populate the Children list on the client. 

    How can I do this? 


  2. GCS
    GCS avatar
    20 posts
    Member since:
    Apr 2013

    Posted 08 Mar 2016 in reply to GCS Link to this post

    Forgot to post my grid, it looks something like: 


                            .Columns(columns =>
                                columns.Bound(l => l.Name);
                                columns.Bound(l => l.Age); 
                            .ToolBar(toolBar =>
                            .DataSource(dataSource => dataSource
                                .Events(events => events.Error("error_handler"))
                                 .Model(model =>
                                     model.Id(l => l.Id);
                                     model.Field(l => l.Id).Editable(false);

  3. Nikolay Rusev
    Nikolay Rusev avatar
    2289 posts

    Posted 10 Mar 2016 Link to this post

    Hello Dave,


    You could handle detailInit event and initialize, client-side with JavaScript, the detail template widget. In the context of the event you have reference to the parent row data item from which you can get the children collection.


    Nikolay Rusev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top