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.
Unfortunately, activation email could not send to your email. Please try again.

Nested Property Goes Infinite

Thread ID:

Created:

Updated:

Platform:

Replies:

39707 Jan 17,2006 12:37 AM Jan 20,2006 11:43 AM Windows Forms 6
loading
Tags: Grouping
Salim Amin Padela
Asked On January 17, 2006 12:37 AM

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 09:53 AM

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 17, 2006 11:53 PM

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 05:25 AM

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 10:52 AM

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 19, 2006 10:43 PM

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 11:43 AM

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

CONFIRMATION

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.

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.

;