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
close icon

GGC and binding to a 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

14 Replies

AD Administrator Syncfusion Team November 17, 2006 11:38 AM UTC

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


AD Administrator Syncfusion Team November 17, 2006 12:15 PM UTC

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


AD Administrator Syncfusion Team November 17, 2006 01:31 PM UTC

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


AD Administrator Syncfusion Team November 20, 2006 10:44 AM UTC

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


AD Administrator Syncfusion Team November 20, 2006 10:45 AM UTC

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


AD Administrator Syncfusion Team November 20, 2006 11:06 AM UTC

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


AD Administrator Syncfusion Team November 21, 2006 11:24 AM UTC

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


AD Administrator Syncfusion Team November 22, 2006 10:43 AM UTC

Hi,

just wanna know if there are any news about that?

Cheers,
Franz


AD Administrator Syncfusion Team November 27, 2006 09:00 AM UTC

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


AD Administrator Syncfusion Team November 27, 2006 09:44 AM UTC

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


AD Administrator Syncfusion Team November 27, 2006 10:19 AM UTC

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


AD Administrator Syncfusion Team November 27, 2006 10:38 AM UTC

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


AD Administrator Syncfusion Team November 27, 2006 10:48 AM UTC

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.


AD Administrator Syncfusion Team November 28, 2006 12:13 PM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon