This is a migrated thread and some comments may be shown as answers.

Show Text Field in Place of Numeric

5 Answers 37 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Neil N
Top achievements
Rank 1
Veteran
Iron
Neil N asked on 20 Mar 2013, 02:28 PM
Example dataset:

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

Sort by
0
Daniel
Telerik team
answered on 25 Mar 2013, 07:30 PM
Hello Neil,

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 1
Veteran
Iron
answered on 27 Mar 2013, 02:23 PM
This is the PivotGrid forum. I'm using a PivotGrid.
0
Accepted
Daniel
Telerik team
answered on 01 Apr 2013, 07:20 AM
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.
<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 1
Veteran
Iron
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
Daniel
Telerik team
answered on 02 Apr 2013, 03:01 PM
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
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.
Tags
PivotGrid
Asked by
Neil N
Top achievements
Rank 1
Veteran
Iron
Answers by
Daniel
Telerik team
Neil N
Top achievements
Rank 1
Veteran
Iron
Share this question
or