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

grid groups

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 16 Aug 2013, 03:47 PM
Is there any way to add a button to a grid group (when grouping).

I.e. if I am grouping by categories, on each "category" I could add a "delete" button, that would call code and act on all the records in that category.

Thanks, Erik.

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 20 Aug 2013, 10:59 AM
Hi Erik,

 
Please check the example below of adding button to the group header which on click delete the items in current group on current page (you can modify this example to achieve the desired behavior):

  • Add groupHeaderTemplate:
    groupHeaderTemplate: "<button onclick='deleteGroup(this)'>delete group</button>"
  • Add deleteGroup event handler:  
    function deleteGroup(e) {
        var grid = $("#grid").data("kendoGrid");
        var groupItems = grid.dataItem($(e).closest("tr")).parent();
     
        for (var i = 0; i < groupItems.length; i++) {
            grid.dataSource.remove(groupItems[i]);
        }
        grid.saveChanges();
    }
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Erik
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or