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

Grid CRUD operations loading data form DataTable object

1 Answer 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 14 Mar 2013, 08:52 PM
I'm having problems to add/edit/delete rows on a grid loaded from DataTable

I have something like the following code:
@(Html.Kendo().Grid<object>()
        .HtmlAttributes(new { style = "height: 80%;" })
        .Name("grid-records")
        .Columns(columns =>
        {
            columns.LoadSettings(Model.GridColumns);
            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.Container.DataSource.Schema.Model.Fields.Add(modelField);
            }
            //columns.Command(command => { command.Edit(); command.Destroy(); }).HtmlAttributes(new { style = "float:right;" });
            columns.Command(command => command.Custom("ViewDetails"));
        })
        .Groupable()
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable(Web.Helpers.KendoI18n.SetGridFilterableSettings)
        //.Editable(editable => editable.Mode(GridEditMode.InLine))
        .DataSource(dataSource => dataSource
            .Ajax()
            .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?

Thanks

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 18 Mar 2013, 04:43 PM
Hello Alberto,

The question is already discussed in this forum thread:


http://www.kendoui.com/forums/mvc/grid/problem-with-crud-operation-with-data-table-as-model.aspx

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!
Tags
Grid
Asked by
Alberto
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or