Mat
Mat

Reputation: 1688

Kendo grid editRow method: suppress popup

I've to created a customised 'update' button for a Kendo Grid.

Basically, it programmatically puts the appropriate row into edit mode (using editRow), updates some fields to specific values (using model.set) and then saves the row (using saveRow).

It's working, but it displays the popup edit window as soon as the editRow method is called, which is slowing down the process and doesn't look good.

Is there a way to suppress the popup when modifying data programmatically? This is what I'm doing (there may be an alternative/better way to do this):

    columns: [
        ....
        { command: [{name: 'edit' }, {name: 'approval'}, {name: 'delrow'}] }
    ],
    dataBound: function() {

        grid.find('.k-grid-approval').click(function() {
            var row = $(this).parents('tr:first');
            var g = requisitions.data('kendoGrid');
            var data = g.dataItem(row[0]);
            var model = g.dataSource.getByUid(data.uid);
            g.editRow(row[0]);
            model.set('status', 'Pending');
            model.set('date_submitted', moment().toDate());
            g.saveRow();
        });

I suspect there's a better way to do this, but I don't know what it is. Any advice is much appreciated.

Upvotes: 2

Views: 2290

Answers (1)

Mat
Mat

Reputation: 1688

I was right... there is a better way:

dataBound: function() {

    grid.find('.k-grid-approval').click(function() {
        var row = $(this).parents('tr:first');
        var g = requisitions.data('kendoGrid');
        var data = g.dataItem(row[0]);
        var model = g.dataSource.getByUid(data.uid);
        // g.editRow(row[0]);
        model.set('status', 'Pending');
        model.set('date_submitted', moment().toDate());
        // g.saveRow();
        // editRow and saveRow are not required -- just use dataSource.sync()
        g.dataSource.sync();
    });

Upvotes: 6

Related Questions