Problem with CRUD operation with Data table as Model

Thread is closed for posting
5 posts, 0 answers
  1. Arun
    Arun avatar
    1 posts
    Member since:
    Dec 2012

    Posted 04 Dec 2012 Link to this post

    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"))    
        )
    )

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 05 Dec 2012 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Alberto
    Alberto avatar
    4 posts
    Member since:
    Nov 2012

    Posted 14 Mar 2013 Link to this post

    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
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 15 Mar 2013 Link to this post

    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!
  6. Raju
    Raju avatar
    2 posts
    Member since:
    Mar 2013

    Posted 05 Apr 2013 Link to this post

    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"))               
        )
    )
Back to Top
UI for ASP.NET MVC is VS 2017 Ready