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

Problem with CRUD operation with Data table as Model

4 Answers 587 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arun
Top achievements
Rank 1
Arun asked on 04 Dec 2012, 01:22 PM
HI,

   I am working on exploring the grid features of the Kendo UI. I am working on binding the data table to the grid and populating  the data's.
   
I got the sample solution to work on the data table with the grid from the below URL.

URL: http://www.kendoui.com/code-library/mvc/grid/binding-to-datatable.aspx

I am pretty impressed with the Grid View, but when to try to create the  the edit view  mode as INLINE (or ) INCEL in the grid  i am getting the below error.when i try to give the popup in the gridview, I am not getting anything from the data table in popup.

Please suggest me that whether am I trying anything wrong or Kendo UI dosen't support the below functionality.if kendo UI supports this functionality,
 could you please give me the working example ???????

Error:

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


Code Used:

@model System.Data.DataTable

@(Html.Kendo().Grid(Model)
    .Name("Grid")    
    .Columns(columns => {
        columns.Command(command => { command.Edit(); }).Width(100).Title("Edit");
        columns.Command(command => { command.Destroy(); }).Width(100).Title("Delete");
        foreach (System.Data.DataColumn column in Model.Columns)
        {
            columns.Bound(column.DataType, column.ColumnName);     
        }
    })    
   .Editable(ed => ed.Mode(GridEditMode.InCell))
   .ToolBar(toolbar =>
            {
                toolbar.Create();               
                toolbar.Save(); 

            })
   .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource        
        .Ajax()
        .Batch(true)
        .Model(model =>{model.Id(OP => OP.Row[0]);
            model.Field(pd => pd.Row[0]).Editable(false);})
        .Create(update => update.Action("EditingInline_Create", "ModelsView"))
        .Read(read => read.Action("Read", "Home"))
        .Update(update => update.Action("EditingInline_Update", "ModelsView"))
        .Destroy(update => update.Action("EditingInline_Destroy", "ModelsView"))    
    )
)

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 05 Dec 2012, 07:47 AM
Hello Arun,

 The linked code library project already contains a running solution. You should adapt it to your needs. 

 Inline and incell editing are not supported with DataTables because ASP.NET MVC does not support DataTables for generating editor templates (this is what the exception message means).

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alberto
Top achievements
Rank 1
answered on 14 Mar 2013, 07:33 PM
Hi Atanas,

I have the same problem. I don't understand exactly what you mean with "ASP NET MVC does not support DataTables for generating editor templates" ... it means Kendo does not support it?

If it is possible, could you tell me more in deep how I should adapt the solution to work with DataTable?

Thanks
0
Atanas Korchev
Telerik team
answered on 15 Mar 2013, 09:50 AM
Hi Alberto,

 "ASP NET MVC does not support DataTables for generating editor templates" means that ASP.NET MVC doesn't support DataTables when doing Html.EditorForModel/Html.EditorFor. You can verify this in your own project when the model of your view is DataTable. In general ASP.NET MVC (not Kendo UI) isn't oriented towards DataTable objects.

 This is the reason our code library project uses popup editing and not inline editing.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Raju
Top achievements
Rank 1
answered on 05 Apr 2013, 01:36 PM
I have bind a datatable to kendo grid and used .editable as popup. But I got the following error.
The model item passed into the dictionary is of type 'System.Data.DataRowVersion', but this dictionary requires a model item of type 'System.String'.

@model System.Data.DataTable
@(Html.Kendo().Grid(Model)
    .Name("Grid")   
    .Columns(columns =>
    {
        foreach (System.Data.DataColumn column in Model.Columns)
        {            
                columns.Bound(column.ColumnName.ToString());            
        }
    })  
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .Pageable()      
    .DataSource(dataSource => dataSource
        .Ajax()               
        .Model(model =>
            {
                foreach (System.Data.DataColumn column in Model.Columns)
                {
                    model.Field(column.ColumnName, column.DataType);
                }                
            })
        .Read(read => read.Action("SelectPage", "Home"))       
        .Create(create => create.Action("EditingCustom_Create", "Grid"))
        .Update(update => update.Action("EditingCustom_Update", "Grid"))        
        .Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Grid"))               
    )
)
Tags
Grid
Asked by
Arun
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Alberto
Top achievements
Rank 1
Raju
Top achievements
Rank 1
Share this question
or