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.

Dynamically added column to underlying datasource not reflected in ggc

Thread ID:

Created:

Updated:

Platform:

Replies:

53189 Dec 10,2006 03:21 PM Dec 14,2006 04:45 AM Windows Forms 7
loading
Tags: Grouping
James Blibo
Asked On December 10, 2006 03:21 PM

I have a ggc that is bounded to -> dsOrder.Tables["Lines"].

On another tab, I am dynamically adding a column to the datasource and add that columns to the grid visible columns collection to show it. But this is not working. My code snippet is below.

When debugging, I see that the columns is added to the datasource and that the visiblecolumn count goes up by 1, but the grid is not reflecting the change. I have tried gridGroupingControl1.Refresh(); and gridGroupingControl1.Update();


DataColumn col = new DataColumn("col1", typeof(int));
col.DefaultValue = 0;
dsOrder.Tables["Lines"].Columns.Add(col);
dsOrder.Tables["Lines"].AcceptChanges();
this.gridGroupingControl1.TableDescriptor.VisibleColumns.Add("col1");
bool b = this.gridGroupingControl1.TableDescriptor.VisibleColumns.Contains("col1");
gridGroupingControl1.Refresh();

Administrator [Syncfusion]
Replied On December 10, 2006 11:23 PM

Hi James,

After modifying the new data source try calling gridGroupingControl1.TableDescriptor.ResetColumns() to see if that helps.

DataColumn col = new DataColumn("col1", typeof(int));
col.DefaultValue = 0;
dsOrder.Tables["Lines"].Columns.Add(col);
dsOrder.Tables["Lines"].AcceptChanges();
this.gridGroupingControl1.TableDescriptor.ResetColumns();
//Or
this.gridGroupingControl1.TableDescriptor.Columns.Reset();
gridGroupingControl1.Refresh();

Best Regards,
Haneef

James Blibo
Replied On December 11, 2006 11:41 AM

SOrry.. this did not work

Administrator [Syncfusion]
Replied On December 12, 2006 01:56 AM

Hi James,

You can call TableDescriptor.ResetVisibleColumns() method to repopulate VisibleColumn collection from the Tabledescriptor.Columns collection.Please refer to the attached sample for implementation.

Sample : NestedTable_c8c76b11.zip

Best Regards,
Haneef

James Blibo
Replied On December 12, 2006 09:14 AM

It's still not working for me. I have using a CustomEngine with the grid to display the summary rows at the top. I'm not sure if this causing it. I added the custom engine to the project that you sent and i'm getting an error when I run the project.

I've attached the custom engine!

Also, I reported another problem about the CaptionSectionCell getting automatically selected when you click the plus/minus button. I wanted to prevent this behavior. When I added the custom engine to the project that you sent, it was happening. You can add the custom engine and see for yourself. Thanks for the help.

CustomEngine4.zip

Administrator [Syncfusion]
Replied On December 13, 2006 07:46 AM

Hi James,

Please refer to the following sample which demonstrates the adding of columns at run time, it uses the custom engine to have the summary row at the top. Is it possible for you to upload us more details or a demo sample or your property settings? So we would suggest you a better solution at the earliest.

Sample: GGC_AddingColumns.zip

Thank you for being patience.
Have a nice day.

Best regards,
Madhan

James Blibo
Replied On December 13, 2006 09:58 AM

Attached is a snippet of my ggc settings. Basically, just follow the ctor and you'll be able to trace the order.

basically, I have series of columns in the datasource.

I add a couple of expression columns after I get the dataTable.

Then I bind datatable to the grid.

After that I do a...

this.gridGroupingControl1.TableDescriptor.VisibleColumns.Clear();

so I can leave out selected columns that I do not want to display and also change the display order of the columns.

Then I add the summary columns, ect, and lastly I applied some grid settings.



gridsettings.zip

Administrator [Syncfusion]
Replied On December 14, 2006 04:45 AM

Hi James,

Thanks for your code snippet and for being patience.

By Default, the grouping grid will automatically respond to adding/removing columns in the datasource. In case, changing the this.gridGroupingControl1.TableDescriptor.VisibleColumns, the grid will automatically assumes that the user wants to control the columns that are being displayed and no longer will re-act to the adding/removing of columns in the datatable. Therefore, you need to explicitly add/remove the columns from the this.gridGroupingControl1.TableDescriptor.VisibleColumns collection as you add/remove columns from the datatable.

If you want the grid to automatically respond to adding/removing columns in the datatable, please not change the VisibleColumns collection in your code.

Kindly let us know if you need any further information.
Have a nice day.

Best regards,
Madhan

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.

;