ExtendedDatagrid and TableStyles

A

Andrew Donaldson

Hi there,

Long-time lurker, first-time poster:

I'm working with the ExtendedDatagrid
(http://dotnet.leadit.be/extendeddatagrid/) control to display a grid
representing an array of objects I've created.

In the form below the datagrid is displayed with the correct columns,
and the correct data (as added at the bottom of the code with my
partial-datarow). However, this is displayed using the default style,
and not the custom-controls i specified in my styles.

If i uncomment the line that adds my tablestyle to the datagrid,
things appear to break. All that is shown is an empty datagrid.

This has been making me tear my hair out for the last two days. If you
can put me out my misery, or can point out a better way to approach my
problem i'm all ears!

Thanks!

Andrew

code:
-----

DataTable dt = new DataTable("CustomersMatrix");
dt.Columns.Add("Customers");
ft.Columns.Add("SalesMargins");

foreach (string p in Products)
{
dt.Columns.Add(p);
}

// Create datagrid table style
ExtendedDataGridTableStyle ts = new ExtendedDataGridTableStyle();
ts.MappingName = "Customers[]";

// create datagrid column styles for first two columns
ExtendedDataGridControlColumn colCustomerName = new
ExtendedDataGridControlColumn();
colCustomerName.MappingName = "Name";
colCustomerName.HeaderText = "Customers";
colCustomerName.Control = typeof(CustomerLabelColumnControl);

DataGridTextBoxColumn colSalesMarginLabel = new
DataGridTextBoxColumn();
colSalesMarginLabel.MappingName = colSalesMarginLabel.HeaderText =
"SalesMargin";
//colCustomerName.Control = typeof(CustomerLabelColumnControl);

// for each product in the db, create a column style
ArrayList productColumnStyles = new ArrayList();
ExtendedDataGridControlColumn[] productColumnStylesArray;

foreach (string product in Products)
{
ExtendedDataGridControlColumn colProduct = new
ExtendedDataGridControlColumn();
//colProduct.MappingName = "Products";
colProduct.HeaderText = product;
colProduct.Control = typeof(ProductSalesMarginColumnControl);
productColumnStyles.Add(colProduct);
}

productColumnStylesArray =
(ExtendedDataGridControlColumn[])productColumnStyles.ToArray(typeof(ExtendedDataGridControlColumn));

// add all column styles to our tablestyle
ts.GridColumnStyles.Add(colCustomerName);
ts.GridColumnStyles.Add(colSalesMarginLabel);
ts.GridColumnStyles.AddRange(productColumnStylesArray);

// add our tablestyle to the datagrid
//extendedDataGrid.TableStyles.Add(ts);

DataRow dr = dt.NewRow();
dr["Customers"] = "Carrefour";
dr["SalesMargins"] = "Sales\nMargins";
dr["Televisions"] = new CustomerProductMatrix.SalesMargin(100,0.5m);
dt.Rows.Add(dr);

extendedDataGrid.DataSource = dt;
 
S

Sijin Joseph

Change

ts.MappingName = "Customers[];

to

ts.MappingName = "CustomersMatrix";

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph



Andrew said:
Hi there,

Long-time lurker, first-time poster:

I'm working with the ExtendedDatagrid
(http://dotnet.leadit.be/extendeddatagrid/) control to display a grid
representing an array of objects I've created.

In the form below the datagrid is displayed with the correct columns,
and the correct data (as added at the bottom of the code with my
partial-datarow). However, this is displayed using the default style,
and not the custom-controls i specified in my styles.

If i uncomment the line that adds my tablestyle to the datagrid,
things appear to break. All that is shown is an empty datagrid.

This has been making me tear my hair out for the last two days. If you
can put me out my misery, or can point out a better way to approach my
problem i'm all ears!

Thanks!

Andrew

code:
-----

DataTable dt = new DataTable("CustomersMatrix");
dt.Columns.Add("Customers");
ft.Columns.Add("SalesMargins");

foreach (string p in Products)
{
dt.Columns.Add(p);
}

// Create datagrid table style
ExtendedDataGridTableStyle ts = new ExtendedDataGridTableStyle();
ts.MappingName = "Customers[]";

// create datagrid column styles for first two columns
ExtendedDataGridControlColumn colCustomerName = new
ExtendedDataGridControlColumn();
colCustomerName.MappingName = "Name";
colCustomerName.HeaderText = "Customers";
colCustomerName.Control = typeof(CustomerLabelColumnControl);

DataGridTextBoxColumn colSalesMarginLabel = new
DataGridTextBoxColumn();
colSalesMarginLabel.MappingName = colSalesMarginLabel.HeaderText =
"SalesMargin";
//colCustomerName.Control = typeof(CustomerLabelColumnControl);

// for each product in the db, create a column style
ArrayList productColumnStyles = new ArrayList();
ExtendedDataGridControlColumn[] productColumnStylesArray;

foreach (string product in Products)
{
ExtendedDataGridControlColumn colProduct = new
ExtendedDataGridControlColumn();
//colProduct.MappingName = "Products";
colProduct.HeaderText = product;
colProduct.Control = typeof(ProductSalesMarginColumnControl);
productColumnStyles.Add(colProduct);
}

productColumnStylesArray =
(ExtendedDataGridControlColumn[])productColumnStyles.ToArray(typeof(ExtendedDataGridControlColumn));

// add all column styles to our tablestyle
ts.GridColumnStyles.Add(colCustomerName);
ts.GridColumnStyles.Add(colSalesMarginLabel);
ts.GridColumnStyles.AddRange(productColumnStylesArray);

// add our tablestyle to the datagrid
//extendedDataGrid.TableStyles.Add(ts);

DataRow dr = dt.NewRow();
dr["Customers"] = "Carrefour";
dr["SalesMargins"] = "Sales\nMargins";
dr["Televisions"] = new CustomerProductMatrix.SalesMargin(100,0.5m);
dt.Rows.Add(dr);

extendedDataGrid.DataSource = dt;
 
S

Sijin Joseph

Change

ts.MappingName = "Customers[];

to

ts.MappingName = "CustomersMatrix";

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph



Andrew said:
Hi there,

Long-time lurker, first-time poster:

I'm working with the ExtendedDatagrid
(http://dotnet.leadit.be/extendeddatagrid/) control to display a grid
representing an array of objects I've created.

In the form below the datagrid is displayed with the correct columns,
and the correct data (as added at the bottom of the code with my
partial-datarow). However, this is displayed using the default style,
and not the custom-controls i specified in my styles.

If i uncomment the line that adds my tablestyle to the datagrid,
things appear to break. All that is shown is an empty datagrid.

This has been making me tear my hair out for the last two days. If you
can put me out my misery, or can point out a better way to approach my
problem i'm all ears!

Thanks!

Andrew

code:
-----

DataTable dt = new DataTable("CustomersMatrix");
dt.Columns.Add("Customers");
ft.Columns.Add("SalesMargins");

foreach (string p in Products)
{
dt.Columns.Add(p);
}

// Create datagrid table style
ExtendedDataGridTableStyle ts = new ExtendedDataGridTableStyle();
ts.MappingName = "Customers[]";

// create datagrid column styles for first two columns
ExtendedDataGridControlColumn colCustomerName = new
ExtendedDataGridControlColumn();
colCustomerName.MappingName = "Name";
colCustomerName.HeaderText = "Customers";
colCustomerName.Control = typeof(CustomerLabelColumnControl);

DataGridTextBoxColumn colSalesMarginLabel = new
DataGridTextBoxColumn();
colSalesMarginLabel.MappingName = colSalesMarginLabel.HeaderText =
"SalesMargin";
//colCustomerName.Control = typeof(CustomerLabelColumnControl);

// for each product in the db, create a column style
ArrayList productColumnStyles = new ArrayList();
ExtendedDataGridControlColumn[] productColumnStylesArray;

foreach (string product in Products)
{
ExtendedDataGridControlColumn colProduct = new
ExtendedDataGridControlColumn();
//colProduct.MappingName = "Products";
colProduct.HeaderText = product;
colProduct.Control = typeof(ProductSalesMarginColumnControl);
productColumnStyles.Add(colProduct);
}

productColumnStylesArray =
(ExtendedDataGridControlColumn[])productColumnStyles.ToArray(typeof(ExtendedDataGridControlColumn));

// add all column styles to our tablestyle
ts.GridColumnStyles.Add(colCustomerName);
ts.GridColumnStyles.Add(colSalesMarginLabel);
ts.GridColumnStyles.AddRange(productColumnStylesArray);

// add our tablestyle to the datagrid
//extendedDataGrid.TableStyles.Add(ts);

DataRow dr = dt.NewRow();
dr["Customers"] = "Carrefour";
dr["SalesMargins"] = "Sales\nMargins";
dr["Televisions"] = new CustomerProductMatrix.SalesMargin(100,0.5m);
dt.Rows.Add(dr);

extendedDataGrid.DataSource = dt;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top