Kendo grid cancel causing deletion of row

后端 未结 1 1007
悲哀的现实
悲哀的现实 2021-01-24 10:52

I am using kendo grid and the grid.And on a particular situation i am adding data to the datasource of the grid using grid.dataSource.add() method.The following is

1条回答
  •  一生所求
    2021-01-24 11:55

    Your record is being removed because the just added data is being destroyed when you cancel the edition.

    Place a trace on destroy method and you will see it being invoked when you hit cancel and destroy is being invoked because the have actually never been created into the server (place a trace on create handler and you will see that it is not being invoked).

    And create is not being invoked because when you add them in the for loop you assign an id.

    Try the for loop as follow:

    var gridDs      =   $("#itemcode_grid").data("kendoGrid").dataSource;
    for (var i = 0; i < gridData.length; i++) {
        gridDs.add({
            type_flag           : gridData[i].type_flag,
            item_code           : gridData[i].item_code,
            bill_no             : detailsData[i].bill_no,
            item_code_desc      : detailsData[i].itemcode_details.item_code_desc,
            line_balance        : gridData[i].line_deferred,
            collection_status   : detailsData[i].collection_status,
            amount              : parseFloat(gridData[i].amount),
            qty_pricing_type    : detailsData[i].itemcode_details.qty_pricing_type,
            item_detail         : res[0][i],
            total_balance       : parseFloat(detailsData[i].line_balance),
            total_due           : detailsData[i].line_due
        });
    
        gridDs.sync();
    }
    

    Conclusion: it is bad not assigning id but it is bad assigning it to early.

    0 讨论(0)
提交回复
热议问题