kendo jquery grid unbind not working comman add row

1 Answer 20 Views
Grid
Wilmer
Top achievements
Rank 1
Wilmer asked on 22 Feb 2024, 10:13 PM

greetings,

I am currently migrating from kendo version 2015.2.902 to 2023.1.314 for some of the company's core applications and I have the following problem.

When adding the create command to any grid, adding a new row is not working, if I disable the following code in the ondatabound event

function onGridDataBound() {
    /*$('.k-grid-add').unbind("click");*/

    $('.k-grid-add').bind("click", function () {
        if (esModuloAtributos() && configuradorUtils.mode === "edit") {
            setKendoDropDownInitSelection("xxxx");
            setKendoDropDownInitSelection("xxxxx");
        } else if (esModuloAgrupaciones() && configuradorUtils.mode === "edit") {
            setKendoDropDownInitSelection("xxxx");
            setKendoDropDownInitSelection("xxxxxx");
        }
        $("#Todos").prop("checked", false);
        return validaFiltros();
    }); 
}

The grid works to create and add the new row, but it does not maintain the functionality that if x condition is met it should add the row.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 27 Feb 2024, 03:27 PM

Hello Wilmer,

The addition of the row cannot be easily prevented and you could just cancel the row if the validation fails using the canceRow() method:

$("#grid").on("click", ".k-grid-toolbar .k-grid-add", function(e) {
    let grid = $("#grid").data("kendoGrid");
    grid.cancelRow()
});

Also, the code snippet above could be placed outside the grid so you do not attach an event on each databound.

Let me know how that works for you.

Regards,
Nikolay
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Grid
Asked by
Wilmer
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or