DataSource.remove or grid.removeRow?

1 Answer 1794 Views
Grid
Robert Madrian
Top achievements
Rank 1
Veteran
Robert Madrian asked on 14 Nov 2016, 05:54 PM

Hi,

I'm relatively new to Kendo MVC Grid and in the middle of building a new app with it...

I know that it is possible to delete a record if I use the "removeRow" from Kendo Grid if a have a reference to the current row i.e:

var grid = $(gridname).data("kendoGrid");
var tr = $(e.target).closest("tr");
grid.removeRow(tr);

but what if I have no reference to the current row (e.target) because I want to delete a selected row from another popup view (see Picture)?
the following Code does'nt work:

var grid = $("#grid").data("kendoGrid");
var dataitem = grid.dataItem(grid.select());
grid.dataSource.remove(dataitem);
grid.dataSource.sync();

 

please give me the info how is the best approach to remove a selected row from grid in my Situation?

regards robert

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 15 Nov 2016, 07:45 AM

Hello Robert Madrian,

The difference between methods is that `removeRow` may show confirmation based on the Grid setup and will automatically call `dataSource.sync`  if in `inline | popup` edit mode.

That said the second code snippet should work for you. Bellow I've listed possible reasons what you should check if doesn't work:

 - the model which you are removing is not part of the DataSource. You see the method implementation here.

 - there isn't schema.model.id defined for the DataSource

 

Regards,
Nikolay Rusev
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
Robert Madrian
Top achievements
Rank 1
Veteran
commented on 15 Nov 2016, 09:25 AM

I found the Problem - wrong Controller :-(

thanks a lot

Tags
Grid
Asked by
Robert Madrian
Top achievements
Rank 1
Veteran
Answers by
Nikolay Rusev
Telerik team
Share this question
or