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

Delete Muliple Rows having Checkbox and using common Delete Button

11 Answers 1087 Views
Grid
This is a migrated thread and some comments may be shown as answers.
monsoon
Top achievements
Rank 1
monsoon asked on 04 Jul 2013, 11:53 AM
Could any one help me how to delete muliple Rows in grid each having checkboxes and by clicking common delete button will delete the selected rows.Clicking on rows apart from checkbox  should not make look like as  selected /enabledor in different colour.
I am using only Kendo UI  web and Framework .. So  my code is like

MyTemplate:
$("#rfgGrid").kendoGrid(
{  
dataSource : DataSource,
editable : true, 
height : 260,
columns : [
{
field : "select",
title : "Select",
width : "16%",
template: "<input type='checkbox' class='checkbox' />"
},
{
field : "name",
title : "Name",
width : "35%"
}] 
});

My Java Script:

$('#rfgGrid input:checked.checkbox').each(function(){
 var dataItem1= grid.dataItem($(this).closest('tr'));
grid.dataSource.remove(dataItem1);
}

By this only one row is got deleted even if I select many in the check box..

could any one guide me or help me wit code on http://jsfiddle.net or http://jsbin.com..

Regards,
Winds


11 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 04 Jul 2013, 02:30 PM
Hi Winds,

You can find all the checked inputs and remove the row that they reside on like this:

$("#grid").find("input:checked").each(function(){
            grid.removeRow($(this).closest('tr'));
          })

I have created a JSBin with this implementation, showing how to delete multiple rows based on a checkbox:

http://jsbin.com/ijugav/8/edit
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
monsoon
Top achievements
Rank 1
answered on 05 Jul 2013, 10:45 AM
Thank you very much for your timely help Kiril.. But I end up with multiple confirmation alert for each row Instead I need only one alert prompt altogether.Can you please help me ...my editable is "editable:"true inline"thanks in Advance,
0
monsoon
Top achievements
Rank 1
answered on 05 Jul 2013, 10:46 AM
Thank you Kiril. But I end up with multiple confirmation alert for each row Instead I need only one alert prompt altogether.Can you please help me . I use "editable:"true inline"
0
Kiril Nikolov
Telerik team
answered on 05 Jul 2013, 11:12 AM
Hello Winds,

You can use editable.confirmation configuration property to prevent the confirmation dialogs. Please keep in mind that at the moment it is not possible to delete multiple rows and show only one confirmation window. The DataSource remove() and the Grid removeRow() methods take only one argument, therefore it is not possible to limit the number of confirmations.

I have modified the JSBin to show the new implementation.

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
monsoon
Top achievements
Rank 1
answered on 08 Jul 2013, 06:48 AM
Thank you very much for your timily help  Kiril..I accomplish the requirement through my  custom coding..like by making confiramtion:false in editable and using HTML confirm();.Thank you
0
Razack
Top achievements
Rank 1
answered on 30 Sep 2014, 10:26 AM
This only removes from current pages. But I need to remove from multiple pages at a time. So I tried with 
grid.dataSource.data().remove(item); 
It is working for few items. If selected records are big(say 70 records), it makes hanging problem. See my code blelow

function callOnDelete(gridName, arrayName) {
var grid = $('#' + gridName).data('kendoGrid');
var data = grid.dataSource.data();

//No of records to be deleted
var arrayLength = Object.keys(arrayName).length;

for (var i = 0; i < data.length; i++) {
var dataItem = data[i];

if (dataItem.hasOwnProperty('uid')) {
if (arrayName[dataItem['uid']]) {
data.remove(dataItem);
arrayLength = arrayLength - 1;
if (arrayLength <= 0) break;
}
}
}
}
0
Kiril Nikolov
Telerik team
answered on 01 Oct 2014, 08:41 AM
Hi Razack,

As your question differs from the original topic, would you mind opening a separate support request with more detailed information on the issue that you are facing and a runnable sample of what you have tried so far and we will be happy to help!

Thank you in advance for your cooperation.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rajeev
Top achievements
Rank 1
answered on 08 Jul 2015, 07:43 PM
In my case it deletes only the first row
0
Kiril Nikolov
Telerik team
answered on 09 Jul 2015, 09:00 AM

Hello Rajeev,

 

Please open a separate support request with a runnable sample and we will be happy to help you.

 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
MOTASH
Top achievements
Rank 1
answered on 24 Apr 2018, 08:53 PM
is still not possible to delete multiple rows with single confirmation(as a batch operation),i'm using kendo 2018.1.117
0
Viktor Tachev
Telerik team
answered on 26 Apr 2018, 11:07 AM
Hello,

Please submit each new query in a separate thread. This way the information in a given thread will be consistent and easier to use as reference. 

With that said, in order to delete multiple records in the Grid programmatically you can use the following approach.


An alternative approach would be to call DataSource remove method for each item that should be deleted. After this call sync() again to submit request to the server. 


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
monsoon
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
monsoon
Top achievements
Rank 1
Razack
Top achievements
Rank 1
Rajeev
Top achievements
Rank 1
MOTASH
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or