Example dataset:
Is it possible to show "Yes" for 1 and "No" for 0 while still retaining aggregate functionality? Basically, the aggregate should be a sum which is a count of "Yes".
| Company | Material | Collected |
| A | Stone | 1 |
| A | Wood | 0 |
| A | Marble | 1 |
| A | Plastic | 1 |
| B | Stone | 0 |
| B | Wood | 0 |
| B | Marble | 0 |
| B | Plastic | 1 |
| C | Stone | 1 |
| C | Wood | 1 |
| C | Marble | 1 |
| C | Plastic | 1 |
Is it possible to show "Yes" for 1 and "No" for 0 while still retaining aggregate functionality? Basically, the aggregate should be a sum which is a count of "Yes".
5 Answers, 1 is accepted
0
Hello Neil,
A possible approach is shown below:
Let me know whether this way is suitable for you.
Regards,
Daniel
the Telerik team
A possible approach is shown below:
<telerik:RadGrid ID="RadGrid1" runat="server" ShowFooter="true"> <MasterTableView> <Columns> <telerik:GridTemplateColumn DataField="Bfield" HeaderText="Bfield" UniqueName="Bfield" Aggregate="Count"> <ItemTemplate> <%# ((bool)Eval("Bfield")) ? "Yes" : "No" %> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView></telerik:RadGrid>Let me know whether this way is suitable for you.
Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 27 Mar 2013, 02:23 PM
This is the PivotGrid forum. I'm using a PivotGrid.
0
Accepted
Hello Neil,
Excuse me for this omission. Working with RadPivotGrid templates is quite similar to RadGrid and the other databound controls. The only difference is that you don't have to use Eval. Just write Container.DataItem and then cast the result to the underlying type.
I doubt however, that the aggregated data will return only 1 and 0 as there are not many cases (for example you can have bit field with min/max aggregate) where this would happen.
Best regards,
Daniel
the Telerik team
Excuse me for this omission. Working with RadPivotGrid templates is quite similar to RadGrid and the other databound controls. The only difference is that you don't have to use Eval. Just write Container.DataItem and then cast the result to the underlying type.
<telerik:PivotGridAggregateField DataField="YourDataField"> <CellTemplate> <%# (YourType)Container.DataItem == 0 ? "Yes" : "No" %> </CellTemplate></telerik:PivotGridAggregateField>I doubt however, that the aggregated data will return only 1 and 0 as there are not many cases (for example you can have bit field with min/max aggregate) where this would happen.
Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 01 Apr 2013, 04:10 PM
Thanks, adapting your example to VB.NET works great.
<CellTemplate><%# IIf(CBool(Container.DataItem), "Yes", "No")%></CellTemplate>0
Hello Neil,
I'm glad to hear that you have managed to achieve this functionality. You may also want to examine our online resources:
How to Customize Telerik's ASP.NET PivotGrid Cells Using the Built-in Templates blog post
PivotGrid Templates documentation
PivotGrid Templates example
Best regards,
Daniel
the Telerik team
I'm glad to hear that you have managed to achieve this functionality. You may also want to examine our online resources:
How to Customize Telerik's ASP.NET PivotGrid Cells Using the Built-in Templates blog post
PivotGrid Templates documentation
PivotGrid Templates example
Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.