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.

changing datasource at runtime without rebuilding entire grid columns when datasources have some columns in common

Thread ID:

Created:

Updated:

Platform:

Replies:

52394 Nov 28,2006 02:17 AM Nov 28,2006 04:52 AM Windows Forms 1
loading
Tags: Grouping
jamesb
Asked On November 28, 2006 02:17 AM

I am building a highly dynamic grid using the ggc.

The grid is to be dynamically bound to the two datatables. I want to use one ggc to accomplish this.

The data looks like this ...

datatable1 => id, name, rate, week1, week2, week3
datatable2 => id, name, rate, week4, week5, week6, week7
datatable2 => id, name, rate, week8, week9

The id, name, and rate columns for the two datatable have the same datatypes.
The week columns (week1, week4, ect) is dynamic and is different between the two datatables).

I want to rebind the grid at runtime to a a specific datatable based on the selection from a combo box.

How can I accomplish this without dynamically rebuilding the entire grid over again when I change datasource?
Can I reuse the id, name, and rate columns between the datatables since they are the same and only re-contruct the week columns?
Is there an easy way to save conditional formats and other formatting info between each datatables views so that I do not lose them?
How can I just show the id, name and week1...9 columns and NOT show the rate column (do I bind the datasource before I remove the columns or is it the other way around)?

Administrator [Syncfusion]
Replied On November 28, 2006 04:52 AM

Hi James,

You can add UnBoundFieldDescriptor for the columns that you want to dynamically change from either table to the grid. Then make one table the grid’s datasource and use .QueryValue event to dynamically provide the values from the other table. If you want to handle editing, you would also have to handle SaveValue event.

this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("TableColumnTwo0");
this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("TableColumnTwo1");
this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("TableColumnTwo2");

//Used for saving/Editing the data in the filed.
private void gridGroupingControl1_SaveValue(object sender, FieldValueEventArgs e)
{
GridTable table = this.gridGroupingControl1.GetTable(e.TableDescriptor.Name);
int iRecordIndex = table.UnsortedRecords.IndexOf(e.Record);
string sColumnName = e.Field.Name;
table2.Rows[iRecordIndex][sColumnName] = e.Value;
}

//For display purpose....
private void gridGroupingControl1_QueryValue(object sender, FieldValueEventArgs e)
{
GridTable table = this.gridGroupingControl1.GetTable(e.TableDescriptor.Name);
int iRecordIndex = table.UnsortedRecords.IndexOf(e.Record);
string sColumnName = e.Field.Name;
e.Value = table2.Rows[iRecordIndex][sColumnName];
}

Please refer the sample for implementation.
CombineTables.zip

Best Regards,
Haneef

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.

;