Working with Kendo Grid Hierarchy - Edit rows

2 posts, 0 answers
  1. Safira
    Safira avatar
    3 posts
    Member since:
    Apr 2013

    Posted 07 Aug 2013 Link to this post

    Hi everyone,
    I am using Kendo Grid Hierarchy in my ASP.Net MVC application.

    For each row in my parent table, i have an option to add a child table.

    My parent table is associated with a model. Each row in this parent table has several columns:
    - ID
    - Name
    - Amount
    - Button
    Every time i add a parent row, all values are empty (ID and Name).

    Now, here is my problem:

    When my parent row has a child table filled with rows, e need to hide the button in the parent row. 
    When i remove my child table, i need to show the buttons again.
    I also need to fill a hidden column in the child table, which indicates me who is the parent row.

    How can i do this, only in the client side (using javascript)? I want to edit my information inline, and i would like to make a post only after my editing is completed, serializing my table to JSON and sending it to the server.

    Thanks in advance.

    Best regards
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 Aug 2013 Link to this post

    Hello Safira,

     Hiding and showing the button can be done with a client template. Something like this:

      ClientTemplate("# if (!HasChildren) { # <button class='k-button'>Detail</button> # } #")

     Where HasChilren is a field of the model telling whether the current data item has children or not.

     To set fields of the child grid you need to use its data source and its API.

     Sending the whole child table as JSON won't be that easy though. The child grid is a grid of its own with its separate DataSource configuration (action methods which will perform CRUD). You can check this tutorial for a sample implementation: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/client-detail-template#client-hierarchy

    Let us know if you have further questions!

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