0

I have a kendo grid that shows fetch data from sql using UA function, the grid is dynamic and i am able to view the details i want. I want to be able to delete, edit the given data. I though one idea can be taking the attributes given in this table and use them in other functionto edit or delete in the database. The problem now is that i can not edit or fetch these details from the grid table by any means, i tried adding .Destroy to the grid or any command function but not working.

Here is the code for the grid:

@(Html.Kendo().Grid<dynamic>()
.Name("BrowseGrid")
.Columns(columns =>
{
    foreach (System.Data.DataColumn c in Model.GridNodes.Columns)
    {
        columns.Bound(c.ColumnName).EditorTemplateName("String");
    }
})
.Scrollable()
.DataSource(dataSource => dataSource
    .Ajax()
    .Events(events => events.Error("error_handler"))
    .Model(model =>
    {
        foreach (System.Data.DataColumn column in Model.GridNodes.Columns)
        {
            model.Field(column.ColumnName, column.DataType);
            model.Id("Id");
        }
    })
    .Read(read =>

        read.Action("BrowseGrid", "Configuration")
    )

)
        .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(new int[] { 10})
        .ButtonCount(10)
    ) )

Any suggestions??

KamalF
  • 105
  • 1
  • 3
  • 19
  • you want to do those operations in line, with a popup or in a separate screen? – cycopepe Sep 18 '15 at 19:06
  • I tried to implement this before but i failed and gave up, it's every hard to edit, delete inline in a grid when deal with dynamic objects. Instead of dealing with dynamic objects i created a utility class to bind to the grid. – warrior Sep 18 '15 at 20:06
  • @cycopepe Inline would be better for me, like adding a delete button and edit button in two more columns and when delete is pressed it removes the data from the grid as well as calling a function, passing the attributes in the selected row to be able to delete this selected row from database, same done with edit – KamalF Sep 21 '15 at 07:36
  • @din i think i will reach the same conclusion, can you give me an example how you did it. Thanks – KamalF Sep 21 '15 at 07:38

1 Answers1

0

change to:

.Destroy(update => update.Action("Process_Destroy", "controller name"))
and in controller,

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Process_Destroy([DataSourceRequest] DataSourceRequest  request, ProductViewModel product)
{
if (product != null)
{
    //write your code for delete action;
}

return Json(ModelState.ToDataSourceResult());
}

This will work.

This is perfectly working but not for a dynamic grid, as a dynamic grid will cause some problems within the Kendo UI.

KamalF
  • 105
  • 1
  • 3
  • 19