Sfdatagrid loop deletes the items selected by the checkbox?
I want to pass the "select" Row, and if the checkstate is check, delete it.
Thank you!
CODE:
private void Button1_Click(object sender, EventArgs e)
{
var records = sfDataGrid1.View.Records;
foreach (var record in records)
{
var dataRowView = record.Data as DataRowView;
if (dataRowView != null)
{
var selected = dataRowView.Row["select"];
if (selected.GetType() != typeof(DBNull) && (bool)selected)
{
sfDataGrid1.DeleteSelectedRecords();
}
}
}
}
SIGN IN To post a reply.
3 Replies
JP
Jagadeesan Pichaimuthu
Syncfusion Team
April 22, 2019 09:08 AM UTC
Hi Jiamingliang,
Thanks for using Syncfusion product.
Your requirement can be achieved by enable the AllowDeleting property to true and then add the records in SelectedItems property before calling the DeleteSelectRecords method. Please find the code snippet below to achieve your requirement,
|
// Add in constructor
this.sfDataGrid1.AllowDeleting = true;
private void button1_Click(object sender, EventArgs e)
{
var records = sfDataGrid1.View.Records;
sfDataGrid1.SelectedItems.Clear();
foreach (var record in records)
{
var dataRowView = record.Data as DataRowView;
if (dataRowView != null)
{
var selected = dataRowView.Row["select"];
if (selected.GetType() != typeof(DBNull) && (bool)selected)
{
sfDataGrid1.SelectedItems.Add(record.Data);
}
}
}
sfDataGrid1.DeleteSelectedRecords();
} |
Please find the sample from below link,
Before deleting records please find the screen shot below,
And please find the below screen shot which after delete the records,
If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further.
Regards,
Jagadeesan
JM
JM
April 22, 2019 09:23 AM UTC
OK!!!!good!
Code is very cool
JP
Jagadeesan Pichaimuthu
Syncfusion Team
April 22, 2019 09:39 AM UTC
Hi Jiamingliang,
Thanks for your update.
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.
Regards,
Jagadeesan
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
JM JM
- Apr 21, 2019 10:33 AM UTC
- Apr 22, 2019 09:39 AM UTC