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

Formatting Columns in GridGrouping Control

Hi,
I am trying to format various columns in the GridGrouping Control but have not been able to. In the sample code enclosed I have a ViewGrid working the way I would like it to work (via code). I basically remove all the columns first in the grid, create a datatable and populate the data, then I go through the colums and create a BoundColumn for each column in the grid. In the BoundColumn I can specify the DataFormatString and quickly format the data. Does the GridGrouping Control handle something like this. I found an sample on the web site but it was not too clear to me how the columns were being formatted.

Thanks.
David.

FillGrid.zip

5 Replies

GB Gokul B Syncfusion Team February 21, 2007 06:56 PM UTC

Hi David,

Sorry for the delay in getting back to you.

Attached is the sample which is the modified version of "FillGrid.zip"

FormattingGrid_Forum56753.zip

* In our sample we bind the GridGroup with the Datatable.
* We format the data and display name of the column header using QuerycellStyleInfo event. Could you please update us is this the one you are mentioning?

Please have a look at our attached sample for your references.

Let us know if you have any other queries.

Thanks for using Syncfusion product.

Regards,
Gokulkumar.B


DA David A. Gonzales February 22, 2007 05:19 PM UTC

Thanks. This works like a charm.

David.


DA David A. Gonzales February 22, 2007 06:12 PM UTC

Well, I tried to use the QueryCellStyleInfo to add formatting but now all my buttons will stop firing any events. Anybody have this type of problem? If I take the code out that does the formatting the buttons work again.

Thanks.
David.


DA David A. Gonzales February 22, 2007 08:20 PM UTC

After playing around I came up with a solution to my problem with using the QueryCellStyleInfo event. Instead of defining the formats at that stage I did the following:

protected void SetGridColumnFormat()
{
NotitiaLoginManager l = new NotitiaLoginManager(cConnect);
NotitiaUser nu = l.GetUser(sUser);
NotitiaDataManager nDM = new NotitiaDataManager(nu);
Guid g = new Guid(gStr);

GridEngine engine = GridGroupingControl1.Engine;
GridTableDescriptor parent = (GridTableDescriptor)engine.TableDescriptor;

String sField;
String sFormat;

sFormat = "N4"; // default format
for (int i = 0; i < parent.Columns.Count; i++)
{
sField = parent.Columns[i].MappingName.ToString();
if (sField != "RowID")
{
sFormat = nDM.GetFieldInfo(g, sField, "Format");
parent.Columns[i].Appearance.AnyCell.Format = sFormat;
}

}

}

This is called after I set the DataSource but before I call GridGroupingControl.DataBind().

Works with our custom paging, client-side work and all the rest. Plus it's 3 or 4 times faster than the other method.

David.


GB Gokul B Syncfusion Team February 22, 2007 09:28 PM UTC

Hi David,

Glad that you got it working!.

Let us know if you have any other concerns.

Regards,
Gokulkumar.B

Loader.
Live Chat Icon For mobile
Up arrow icon