This is a migrated thread and some comments may be shown as answers.
Custom button - Add Row in Grid
2 Answers 247 Views
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 24 Aug 2015, 12:19 PM

Hello! I am trying to have a button that adds a row on a grid, that is in GridEditMode.PopUp. However, this button is outside of the grid. Right now I have this:

$("#add").click(function () {
        var grid = $("#grid").data("kendoGrid");
        if (grid) {
            var dataSource = grid.dataSource;
            var total = dataSource.data().length;
            dataSource.insert(total, {});
            dataSource.page(dataSource.totalPages());
            grid.editRow(grid.tbody.children().last());
        }
        return false;
    });
 

but this only displays my popup for a second, before it disappears. If I remove "return false;", the page reloads (as expected). How can I achieve the solution?

 Thanks, 

Manuel

2 Answers, 1 is accepted

Sort by
0
Manuel
Top achievements
Rank 1
answered on 24 Aug 2015, 01:39 PM

Hello again. I was able to solve the proble with the following solution:

$("#add").click(function () {
    var grid = $("#grid").data("kendoGrid");
    grid.addRow();
    return false;
});

Regards,

Manuel

0
Accepted
Dimiter Madjarov
Telerik team
answered on 25 Aug 2015, 07:27 AM

Hello Manuel,

Indeed using the addRow method of the Grid API is the correct approach. Thanks for the update.

Regards,
Dimiter Madjarov
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
Manuel
Top achievements
Rank 1
Answers by
Manuel
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or