Cell Renderer
I''m using a GridGroupingControl and I am wondering what is the easiest way to create a custom renderer. There is no user input in the grid and all the data is driven by a datasource. I need this renderer:
1) Depending on whether the value in the column is less than or greater than a billion, display "M" or "B" at the end. So 100,000 -> .1M. 1,000,000,000 -> 1B
SIGN IN To post a reply.
3 Replies
AD
Administrator
Syncfusion Team
December 13, 2005 11:22 PM UTC
The simplest way to handle this is to subscribe to the TableControlDrawCellDisplayText.
private void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if(style != null && (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
&& style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.Name == "Col1")
{
double d = (double)style.CellValue;
if(d > 1000000000)
{
e.Inner.DisplayText = string.Format("{0:#.##}B", d / 1000000000);
}
else
{
e.Inner.DisplayText = string.Format("{0:#.##}M", d / 1000000);
}
}
}
ST
Stephen
December 14, 2005 01:02 AM UTC
Thanks Clay. Is there a way to do this using a renderer class that I can just attach to whichever columns I choose? Thanks.
>The simplest way to handle this is to subscribe to the TableControlDrawCellDisplayText.
>
>
>private void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
>{
> GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
> if(style != null && (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
> || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
> && style.TableCellIdentity.Column != null
> && style.TableCellIdentity.Column.Name == "Col1")
> {
> double d = (double)style.CellValue;
> if(d > 1000000000)
> {
> e.Inner.DisplayText = string.Format("{0:#.##}B", d / 1000000000);
> }
> else
> {
> e.Inner.DisplayText = string.Format("{0:#.##}M", d / 1000000);
> }
> }
>}
>
AD
Administrator
Syncfusion Team
December 14, 2005 01:54 AM UTC
You could use this code from a renderer but it might be simpler to just wrap it in a helper class. Here is a little sample.
http://www.syncfusion.com/Support/user/uploads/GGC_TextBoxFilter_45059fa0.zip
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
ST Stephen
- Dec 13, 2005 10:31 PM UTC
- Dec 14, 2005 01:54 AM UTC