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.

GGC and binding to a business object

Thread ID:

Created:

Updated:

Platform:

Replies:

51957 Nov 17,2006 06:05 AM Nov 28,2006 07:13 AM Windows Forms 14
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 17, 2006 06:05 AM

Hi together,

we have implemented a business object which implements IBindingList and ITypedList for databinding to a GGC.

Example could be:

public class MyTable : BindingList, ITypedList

Now the MyRow class contains several properties e.g.

public class MyRow
{
public string Name;
public double Number;
public CustomType MyType
...
}

After binding the business object (MyTable) to the grid, I see the "Name" column and the "Number" column. But for the MyType property I see something like "MyType_PropertyName". So I thought I have to override the ToString() method in the CustomType class, but this doesn't change anything.

When I take a look in the ITypedList implementation of GetItemProperties, the PropertyDescriptor.Name attribute shows me the correct naming "MyType".

What's wrong here - Any help would be great.

Cheers,
Franz

Administrator [Syncfusion]
Replied On November 17, 2006 06:38 AM

Hi Franz,

Use the GridColumnDescriptor to change the header text of the columns in a grid. Here is a code snippet.

this.grid.TableDescriptor.Columns[3].HeaderText = "ColumnNameHere";

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 17, 2006 07:15 AM

Thanks for your fast answer. I know that I can change the column name. But the corresponding propertydescriptor already contains the name I want ("MyType"). So I am wondering, why syncfusion is changing that name while binding the business object?


>Hi together,

we have implemented a business object which implements IBindingList and ITypedList for databinding to a GGC.

Example could be:

public class MyTable : BindingList, ITypedList

Now the MyRow class contains several properties e.g.

public class MyRow
{
public string Name;
public double Number;
public CustomType MyType
...
}

After binding the business object (MyTable) to the grid, I see the "Name" column and the "Number" column. But for the MyType property I see something like "MyType_PropertyName". So I thought I have to override the ToString() method in the CustomType class, but this doesn't change anything.

When I take a look in the ITypedList implementation of GetItemProperties, the PropertyDescriptor.Name attribute shows me the correct naming "MyType".

What's wrong here - Any help would be great.

Cheers,
Franz

Administrator [Syncfusion]
Replied On November 17, 2006 08:31 AM

One addition to my previous posting. I have just tested the same business object with the microsoft datagridview control and there, everything is fine.
I have attached a sample where you can see what happens.

Any idea?

PS: I don't want to replace the header (via TableDescriptor), cause I don't know which index to replace (the grid is always bound to another business object)

Cheers
Franz



>Hi Franz,

Use the GridColumnDescriptor to change the header text of the columns in a grid. Here is a code snippet.

this.grid.TableDescriptor.Columns[3].HeaderText = "ColumnNameHere";

Best Regards,
Haneef

BindingExample.zip

Administrator [Syncfusion]
Replied On November 20, 2006 05:44 AM

After some further investigations I noticed that the problem only exists for the GGC. The databound grid works as expected (as the datagridview from MS does). I have attached the sample with some modification, perhaps you can take a look at it. So what property of the PropertyDescriptor is used for the column names in the GGC. How can i solve that issue without setting a different column header in the grid. It would be great if I could solve the problem in the data itself.

Thanks in advance



BindingExample0.zip

Administrator [Syncfusion]
Replied On November 20, 2006 05:45 AM

After some further investigations I noticed that the problem only exists for the GGC. The databound grid works as expected (as the datagridview from MS does). I have attached the sample with some modification, perhaps you can take a look at it. So what property of the PropertyDescriptor is used for the column names in the GGC. How can i solve that issue without setting a different column header in the grid. It would be great if I could solve the problem in the data itself.

Thanks in advance



BindingExample1.zip

Administrator [Syncfusion]
Replied On November 20, 2006 06:06 AM

After some further investigations I noticed that the problem only exists for the GGC. The databound grid works as expected (as the datagridview from MS does). I have attached the sample with some modification, perhaps you can take a look at it. So what property of the PropertyDescriptor is used for the column names in the GGC. How can i solve that issue without setting a different column header in the grid. It would be great if I could solve the problem in the data itself.

Thanks in advance



BindingExample2.zip

Administrator [Syncfusion]
Replied On November 21, 2006 06:24 AM

Hi Franz,

Sorry for the inconvenience caused.

We are looking into this issue and get back to you very soon.

Thanks for your patience.

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 22, 2006 05:43 AM

Hi,

just wanna know if there are any news about that?

Cheers,
Franz

Administrator [Syncfusion]
Replied On November 27, 2006 04:00 AM

Just wanna bring this thread up. We are currently stuck in our evaluation. Can you take a look at our issue please?

Thanks in advance

Cheers,
Franz

Administrator [Syncfusion]
Replied On November 27, 2006 04:44 AM

Hi Franz,

This behaviour is by design. When you bind a business object which itself contains some custom objects (like "Test" object in your example), the grouping grid will go down into the hierarchy and will create one column descriptor for each and every column in this hierarchy. Suppose if your 'Test' class contains two members, the grouping grid will display these two columns and their record values where as the datagrid or databound grid will not show the record values.

Here is a modified sample.

Thanks for your patience.

Best Regards,
Srividhya R

BindingExample3.zip

Administrator [Syncfusion]
Replied On November 27, 2006 05:19 AM

Thanks for your answer,

so this means I can't get the same behavior with the GGC as the databound or datagridview without adding gridcolumn descriptor manually?

Cheers,
Franz

Administrator [Syncfusion]
Replied On November 27, 2006 05:38 AM

Hi Franz,

Yes, you need to create column descriptor for this. Still I am not clear with your requirements.

Do you want to show all the columns in Test object?

Regards,
Srividhya R

Administrator [Syncfusion]
Replied On November 27, 2006 05:48 AM

Hmm,

my requirement is to avoid setting gridcolumn descriptors. I just want to set the datasource and then all information should come from my model (data model). Because when I set the gridcolumn descriptors I get a coupling between the grid view and the data model. But as it seems I need a mapping between my data and the view which could be solved via grid columndescriptors as you mentioned. Is there a "best practice" to handle this.

As you asked about which properties I want to see from my "Test" class -> I want to see no property I just want to see the name of the "Test" property.

I am not sure how can I avoid the coupling between the data and the view - I don't wanna hardcode the mapping like:
m_GridCtrl.TableDescriptor.Columns.Add("Column Name", "columnNameID");

Now if somebody adds a new property to the class one has to add a new mapping too.

Administrator [Syncfusion]
Replied On November 28, 2006 07:13 AM

Hi Franz,

To avoid showing the inner most property you can try handling the Engine.QueryShowNestedPropertiesFields event and set the Cancel to true.

this.gridGroupingControl1.Engine.QueryShowNestedPropertiesFields += new Syncfusion.Grouping.QueryShowNestedPropertiesFieldsEventHandler(Engine_QueryShowNestedPropertiesFields);


void Engine_QueryShowNestedPropertiesFields(object sender, Syncfusion.Grouping.QueryShowNestedPropertiesFieldsEventArgs e)
{
e.Cancel = true;
}

Otherwise the Engine will loop through and get the inner most property.

Let me know if you have further queries.

Best Regards,
Srividhya R

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.

;