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

Bug with removing row programmatically

2 Answers 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 17 Dec 2015, 02:20 PM

Hi,

I have a grid with editable rows. After editing the row I have a context menu command that processes the data on the row and then I need that row to be removed.

So far everything works well until the moment that I need to remove the row.

I have tried many different ways but the one that is closest to working is this:

// After processing successfully, set grid row to non Edit
gridInstance.cancelRow();

// Grab the active row
var activeRow = $(gridInstance.element).find("tr.k-grid-edit-row");

//Remove the active row

gridInstance.removeRow(activeRow);

 

Even though this works ok on the UI (so the row does get removed successfully), 
I also get this javascript error: Cannot read property 'call' of undefined on the kendo.all.min.js
So there is an internal kendo bug there that you guys need to fix because I can't remove a row without getting this javascript error.

This error is a problem cause it causes other things to break.
Is there a way to remove a row programmatically from a grid without causing kendo bugs ? 

2 Answers, 1 is accepted

Sort by
0
Darren
Top achievements
Rank 1
answered on 17 Dec 2015, 02:29 PM

I also tried this:

                var dataSource = gridInstance.dataSource;
                dataSource.remove(dataModel);
                dataSource.sync();

 It works. The item gets removed. However, I still get the same javascript error afterwards.
 "Cannot read property 'call' of undefined on the kendo.all.min.js"

 

 

0
Zen
Top achievements
Rank 1
answered on 18 Dec 2015, 12:12 PM

Hi Darren,

 var initMenu = function () {
                    menu = $(".menu").kendoContextMenu({
                        target: "#grid",
                        filter: "tbody tr[role='row']",
                        animation: {
                            open: { effects: "fadeIn" },
                            duration: 500
                        },
                        select: function(e) {
                            // Do something on select
                            grid.removeRow(e.target)
                        }
                    });
                };
                initMenu();

 

Try give this inside the databound event http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-dataBound .

Tags
Grid
Asked by
Darren
Top achievements
Rank 1
Answers by
Darren
Top achievements
Rank 1
Zen
Top achievements
Rank 1
Share this question
or