We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Is there an equivalent to the ADO.NETdataTable.Select("expression") method at the ggc level

I am trying to mimick the DataTable.Select("Col1=1 and Col2='b'") method at the ggc level.

I want to select a group a records that meets a certain criteria without setting a filter on the ggc and then take some action on those records, for example, delete those records. How can I accomplish that?

I want to do something like...

RecordsInDetailsCollection recs = this.gridGroupingControl1.....

foreach(Record rec in recs)
rec.Delete();

5 Replies

AD Administrator Syncfusion Team January 29, 2007 09:29 AM UTC

Hi James,

Thanks for being patience.

This can be achieved by using the GridConditionalFormatDescriptor and deleting the records based on the condition. The following is the code snippet, please try it and let us know if you need any further assistance.
>>>>>>>>>>>>>>>>>>Code Snippet <<<<<<<<<<<<<<<<<<<<
GridConditionalFormatDescriptor desc = new GridConditionalFormatDescriptor();
desc.Expression = "[CustomerID] LIKE 'A*'";

this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(desc);
foreach (Record rec in this.gridGroupingControl1.Table.Records)
if (desc.CompareRecord(rec))
rec.Delete();
>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<

Please refer to the following sample for more details
CondnlFormatDesc.zip

Kindly let us know if you need any further assistance.
Have a nice day.

Best regards,
Madhan


JB James Blibo January 29, 2007 04:09 PM UTC

DO I have to iterate thru all the records again to do a comparison before I delete. If I have a thousand records, that'll be too much.

I want to do something like...

DataRow[] rows = DataTable.Select("Name LIKE 'A*'");

foreach(DataRow row in rows)
row.Delete();


AD Administrator Syncfusion Team January 30, 2007 12:49 PM UTC

Hi James,

Thank you for being patience.

Please try the following technique, a filter condition is applied to the grid and it will be reset after the records being deleted. Please refer to the following code snippet and let us know if you need any further assistance.

>>>>>>>>>>>>>>>>>>>>>>>>>>> this.gridGroupingControl1.TableDescriptor.RecordFilters.Add("[CustomerID] LIKE 'A*'");
FilteredRecordsInTableCollection reco = this.gridGroupingControl1.Table.FilteredRecords;
foreach (Record r in reco)
r.Delete();
this.gridGroupingControl1.TableDescriptor.ResetRecordFilters();
>>>>>>>>>>>>>>>>>>>>>>>>>>>

Have a nice day.

Best regards,
Madhan


JB James Blibo February 5, 2007 06:24 PM UTC

The only problem with this is that I have the grid visible, so the user will see the filter being applied in front of them and will be like... "where did the other records go?".

Is there are way that I apply the filter to get the records but not have the filter appied in the UI


JB James Blibo February 6, 2007 05:59 PM UTC

Any suggestion on how to go about this?

Loader.
Live Chat Icon For mobile
Up arrow icon