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

Add child record on Datasource Update

I have a GridGroupingControl that I manually add columns and relationships.  The datasource for the control is a List of custom objects as mapped by the relationships.  The problem I'm having is that when I update the underlying datasource the control is not adding the new nested child relationship record.

The underlying relationships are all using IList collections that are mapped to a database and there is little to no hope of making them BindingLists.   

Is there anyway I can force the gridgroupingcontrol to reread the datasource without it rebuilding the entire control?

Thanks,

Mark


7 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team June 9, 2014 03:51 AM UTC

Hi Mark,

Thanks for your interest in Syncfusion products.

 

 

Query

      Add child  Record on Data Source

 

List Item Reference is an object reference relation for looking up values from a strong typed collection. You can make use of this  below UG link.

 

UG Link :

 http://help.syncfusion.com/ug/windows%20forms/grid/default.htm#!Documents/listitemreferencerel.htm

 Regards,

Muthukumar K



MA Mark June 9, 2014 04:11 PM UTC

Hi Muthukumar K,

Thanks for the response to my question, but I'm a bit confused by your response.  I have the datasource all setup and the classes with the nested relationships is working as expected.  On instantiation of the GridGroupingControl I set the AutoPopulateRelations = false and manually add all the columns and nested relationships to the control.  All that works great until I update the underlying datasource.  Since the nested classes are using IList rather than Bindinglist the GridGroupingControl has no idea that the datasource has been updated and will therefore not add a new record to the nested table when it's added to the nested IList of the sub class.

The last thing I was trying was to add the record to the GridGroupingControl nested table myself, so the control will stay in sync with the datasource, but I haven't been successfully as of yet. 

From getting the parent element I am able to obtain the parent record and from there I tried the following:

NestedTable nestedTable = record.NestedTables[0];

nestedTable.ParentTable.AddNewRecord.SetCurrent();

nestedTable.ParentTable.AddNewRecord.BeginEdit();

// Here is where things broke down because CurrentRecord is null

nestedTable.ParentTable.CurrentRecord.SetValue("ColumnName", newValue);

nestedTable.ParentTable.AddNewRecord.EndEdit();


Thanks for the help,

Mark





MK Muthukumar Kalyanasundaram Syncfusion Team June 15, 2014 04:06 PM UTC

Hi Mark,

Thanks for the update.

 

 Query

Add child  Record on Data Source

 

Grouping is a recursive process whereby a data source may be grouped several times. This leads to the recursive situation of groups having sub-groups and so on. Please you can make use of this  below UG link.

UG Link:  http://help.syncfusion.com/windows%20forms/grouping

 

 Please let us know if you have any concern.

Regards,

Muthukumar K



MA Mark June 16, 2014 06:20 PM UTC

Muthukumar K,

I read through the document link you provided, but that doesn't really tell me anything. I see how the classes interrelate, but I still have no idea how to tell the NestedTable to add the new record that is in the SourceList.

If I do the following starting from the Parent Record of the nested table:

ChildTable childTable = record.NestedTables[0].ChildTable;

int count1 = childTable.Records.Count;

int count2 = childTable.SourceList.Count;

count1 will remain fixed at the number loaded into the control from startup while count2 will continue to increment while items are added to the SourceList.

So how do I tell childTable.Records to reread it's sourceList to load the new records?


Thanks,

Mark





NK Neelakandan Kannan Syncfusion Team June 18, 2014 03:39 AM UTC

Hi Mark,

 

The reported scenario can be achieved by TableDirty Property in GridGroupingControl. If TableDirty property is set to true, the engine won't try to keep anything in synchronization at that time.

 

Please refer the below code:

 

gridGroupingControl1.SourceListListChanged += new Syncfusion.Grouping.TableListChangedEventHandler(gridGroupingControl1_SourceListListChanged);

       

void gridGroupingControl1_SourceListListChanged(object sender, Syncfusion.Grouping.TableListChangedEventArgs e)

        {

            e.Table.TableDirty = true;

        }

 

Note:

If you still have the issue in your end, Please send us your sample. It will help us to overcome the reported scenario ASAP.

 

Please let me know if you have any concerns.

 

Regards,

Neelakandan



MA Mark June 18, 2014 04:42 PM UTC

Neelakandan,

I tried your suggestion, but since my SourceList does not implement a IBindingList the event is never fired.  That being said I can get things to refresh if I set the correct nested Table to is dirty as you suggest in the event method.

So my next question is from either the record or the element what is the most efficient way to get the table that object is associated with, so I can set the TableDirty property for only that nested table?

Thanks,

Mark



NK Neelakandan Kannan Syncfusion Team June 20, 2014 05:20 AM UTC

Hi Mark,

 

Thank you for your update.

 

We have already updated solution to this query .

 

Please refer the below incident for the further details:

 

http://www.syncfusion.com/support/directtrac/incidents/126285

 

Please let me know if you have any concerns.

 

Regards,

Neelakandan


Loader.
Live Chat Icon For mobile
Up arrow icon