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

GridGroupingControl (DirtyRows or storing RecordID''s)

Hi,

What I'm attempting to is trying to keep track of user changes to the grid (grid grouping control). Does the grid control keep a cache of all the records changed (i.e. list of dirty records)?

If not, what I have tried to do is store the record ID's that have changed, but I cannot find a way to retrieve the record using that ID (not the row index). The reason I'm using ID and now RowIndex is that RowIndex can change on sort. I could also just try to get the record from the data source, but don't know how.

Any help?

3 Replies

JJ Jisha Joy Syncfusion Team June 9, 2009 11:16 AM UTC

Hi Jason,

Gridgroupingcontrol does not keep track of all the records changes. Inside QueryCellStyleInfo, you can get the underlying record object directly from the TableCellIndentity. You do not have to find indexes and then index another collection to get the record object. Here is some code showing how you can use the TableCellIdentity to get at the underlying data.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
GridRecord record = e.TableCellIdentity.DisplayElement.GetRecord() as GridRecord;
if (record != null)
{
//to get the raw dataobject, ie the DataRowView from a DataTable datasource
//you can use
object data = record.GetData();
DataRowView drv = data as DataRowView;
if (drv != null)
{
//Console.WriteLine("field0={0} field1={1}", drv[0], drv[1]);
}
}
}


Please let us know if this is not the information you needed.

Regards,
Jisha


AD Administrator Syncfusion Team June 9, 2009 05:49 PM UTC

I'm using the following callback to keep track of dirty rows:

private void gridGroupingControlMain_SourceListRecordChanged(object sender, Syncfusion.Grouping.RecordChangedEventArgs e)
{
if (_dirtyRecordIds.Contains(e.Record.Id) == false)
{ _dirtyRecordIds.Add(e.Record.Id); }
}


As you can see I'm just keeping track of the Record.Id's which does not change (from what I can tell) when the rows get sorted. Is there anyway I can use this Record.Id to retrieve the Record item from the GGC? Or is there some other way I can keep track of dirty records and retrieve them easily?


LS Lingaraj S Syncfusion Team June 16, 2009 01:45 PM UTC

Hi Jason,

Thank you for the update.

If you want to get a record from the Record Id value, then please try using Table.Records collection in GridGroupingControl to achieve this behavior. The Records collection are maintained the Records the records in GridGroupingControl.

Please refer the code below:

public Record GetRecordFromId(int id)
{
foreach (Record rec in this.gridGroupingControl1.Table.Records)
{
if (rec.Id == id)
{
return rec;
}
}
return null;
}


Let me know if you have any queries.

Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon