Grid CRUD operations loading data form DataTable object

2 posts, 1 answers
  1. Answer
    Alberto avatar
    4 posts
    Member since:
    Nov 2012

    Posted 14 Mar 2013 Link to this post

    I'm having problems to add/edit/delete rows on a grid loaded from DataTable

    I have something like the following code:
            .HtmlAttributes(new { style = "height: 80%;" })
            .Columns(columns =>
                foreach (GridColumnSettings item in Model.GridColumns)
                    ModelFieldDescriptor modelField = new ModelFieldDescriptor();
                    modelField.Member = item.Member;
                    modelField.MemberType = item.MemberType;
                    modelField.DefaultValue = null;
                    modelField.IsEditable = true;              
                //columns.Command(command => { command.Edit(); command.Destroy(); }).HtmlAttributes(new { style = "float:right;" });
                columns.Command(command => command.Custom("ViewDetails"));
            //.Editable(editable => editable.Mode(GridEditMode.InLine))
            .DataSource(dataSource => dataSource
                .Events(events => events.Error("error_handler"))
                .Read(read => read.Action("GetRecords", "Records", new { currentTableId = Model.CurrentTableId }))
                //.Update(update => update.Action("UpdateRecordFromGrid", "Design"))
                //.Destroy(destroy => destroy.Action("DeleteRecordFromGrid", "Design"))
    In the above code if I uncomment the "commented lines" .. the exception is:

    "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions." 

    Could you tell me what I should do to enable CRUD operations on this case?

  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 18 Mar 2013 Link to this post

    Hello Alberto,

    The question is already discussed in this forum thread:

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top