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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Nested Property Goes Infinite

Thread ID:





39707 Jan 17,2006 05:37 AM UTC Jan 20,2006 04:43 PM UTC WinForms 6
Tags: Grouping
Salim Amin Padela
Asked On January 17, 2006 05:37 AM UTC

Hi, I am associating one entity to the GGC. GGC has ShowNestedPropertiesFields = true. My entity has one property of its own type like self join. What happens is like it hangs because it finds the same typeof of property in the entity. Example: public class Manager { public string Name { } public Manager Parent { } } As you can see here, Manager class refers to itself. Please let me know how can i stop this recursove looping?

stanleyj [Syncfusion]
Replied On January 17, 2006 02:53 PM UTC

Hi salim, Could you please give me some more information regarding how to implement this issue in a sample. I would really appreciate it, if you could provide us a sample code that exhibits this behavior. We will try analyzing it here. Regards, Stanley

Administrator [Syncfusion]
Replied On January 18, 2006 04:53 AM UTC

Hi Salim, Please try setting the "ShowNestedPropertiesFields = false" and let us know if it helps. Best Regards, Jeba.

Salim Amin Padela
Replied On January 19, 2006 10:25 AM UTC

Hi, ShowNestedproperties = false will work. My problem here is different. let me explain you in detail what i want. I have one class named as Manager. Now in database, i have one table as Manager which holds the data. This table has opne column named as ReportTo. If this column is blank, it means the person is Head. For doing this i have created one property in the Manager Class which refers to itself because it is a self join. I need to refer itself to get the Head of the person which is on the record. Let me describe my class. Class Manager { string _empName; Manager _reportsTo; string EmpName { get { return _empName; } set { _empName=value; } } Manager ReportsTo { get { return _reportsTo; } set { _reportsTo = value; } } } Now here you can see that Manager Class refers itself to hold the data of the Manager of the current employee. I want to display the Manager Details of the Head only once. Now what is happening is I am setting ShowNestedFieldProperties = true. So it goes infinite times to cretate the columns of Manager. I dont want to make it loop recursively. I hope you got it what i am here describing you. Still if not then i will send you dummy project and that will clearify what i want to do. Please let me know the solution to stop the recursive loop.

Administrator [Syncfusion]
Replied On January 19, 2006 03:52 PM UTC

Hi Salim, with the special setup you have I think it is actually best to not let the engine automatically populate the nested fields. Instead you can manually populate fields as follows: _testGrid.ShowNestedPropertiesFields = false; _testGrid.TableDescriptor.Fields.Clear(); _testGrid.TableDescriptor.Fields.Add("Name"); _testGrid.TableDescriptor.Fields.Add("TestEmployer.Name"); _testGrid.TableDescriptor.Fields.Add("TestEmployer.TestPatient"); _testGrid.TableDescriptor.Fields.Add("TestEmployer.TestPatient.TestEmployer"); etc. _testGrid.DataSource = list; Stefan

Salim Amin Padela
Replied On January 20, 2006 03:43 AM UTC

In this case i have to hard code the column names and column descriptors. I am not permitted to do so. My domain entity can be changed. I am not supposed to change the code if my domain entity is changed. I hope you are getting my point.

Administrator [Syncfusion]
Replied On January 20, 2006 04:43 PM UTC

Salim, you can also dynamically loop through the properties in your list and add them manually to the Fields collection. For example try this: FieldDescriptorCollection fields = _testGrid.TableDescriptor.Fields; fields.Clear(); PropertyDescriptorCollection pdc = ListUtil.GetItemProperties(list); for (int n = pdc.Count-1; n >= 0; n--) { PropertyDescriptor pd = pdc[n]; if (ListUtil.IsComplexType(pd)) { // put here condition when to include nested properties. AddNestedProperties(fields, pd.Name, pd.PropertyType, 0); } else fields.Add(pd.Name); } _testGrid.DataSource = list; void AddNestedProperties(FieldDescriptorCollection fields, string prefix, Type propertyType, int level) { PropertyDescriptorCollection pdc = ListUtil.GetItemProperties(propertyType); if (pdc.Count > 0) { foreach (PropertyDescriptor pd in pdc) { // Add here criteria when to step into nested type. if (ListUtil.IsComplexType(pd) && level < 2) AddNestedProperties(fields, prefix + "." + pd.Name, pd.PropertyType, level+1); else fields.Add(prefix + "." + pd.Name); } } } I have attached a sample with this code. Other options you have is to set the Browsable(false) attribute for certain properties. But that is then an all or nothing solution. You could however have a derived class for "TestPatient" and only set Browsable(false) in that derived class for the property. As I understand your problem, the key is that in your scenario you want to get the nested properties for the same type only if it is not more than 2 levels deep. The sample I mentioned before is here: TestSyncfusionIssue.zip Stefan


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon