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

Put a RadChart in a DetailTable

4 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
charles
Top achievements
Rank 1
charles asked on 26 May 2011, 03:54 PM
Hi, for my application i have to create a RadGrid. In this RadGrid there's a list of item and when i click on one of them it opens and we can find inside a GridTableView which have inside of it some text in the first column and in the second column a RadChart. As far as I get, I can display everything but i had to save the RadChart as an image and then put it inside the Grid. But now I have some new things that I have to do and that doesn't work anymore. This way i cant use any mapping from my CodeBehind since it's a simple image. To achieve this i've followed this example http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx. I'm creating my RadChart inside the DetailTableDataBind event and add it to the grid. But if i want to keep the mapping I have to insert the RadChart and not the image of it. If I do that it displays only that: Telerik.Web.UI.RadChart.

Can you help me find the problem please.

4 Answers, 1 is accepted

Sort by
0
Vincent
Top achievements
Rank 1
answered on 09 May 2012, 08:51 PM
I also have the same problem.
I need tu put a RadChart in a RadGrid but in a DetailTables.
When I want to bind de RadChart with some data I do:

 protected void dataBoundRadGrid1(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            chart = item["GraphicColumn"].FindControl("RadChart1") as RadChart;


            if (chart != null) chart.DataBind();
        }
    }

but chart is always null.
0
Princy
Top achievements
Rank 2
answered on 10 May 2012, 06:33 AM
Hello Vincent,

Try the following code to access RadChart in DetailTableView.
aspx:
<telerik:GridTableView Name="Detail" . .></telerik:GridTableView>
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{  
 if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail")
 {
    GridDataItem item = (GridDataItem)e.Item;
    RadChart chart = item.FindControl("RadChart1") as RadChart;
 }
}

Thanks,
Princy.
0
Vincent
Top achievements
Rank 1
answered on 10 May 2012, 12:38 PM
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true" AllowSorting="True" OnNeedDataSource="loadDataGrid"  OnItemDataBound="dataBoundRadGrid1">
            <ClientSettings>
                <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
            </ClientSettings>
            <MasterTableView>
                <DetailTables >
                    <telerik:GridTableView Name="Detail" DataKeyNames="OperationsGrahic" runat="server">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="OperationsGraphic" MasterKeyField="OperationsGraphic" />
                        </ParentTableRelation>
                        <Columns>
                            <telerik:GridTemplateColumn  DataField="OperationsGraphic" UniqueName="GraphicColumn" HeaderText="Graphique" >
                                <ItemTemplate>
                                    <telerik:RadChart ID="RadChart1" runat="server" SkinsOverrideStyles="true"  SeriesOrientation="Vertical" >
                                        <ChartTitle >
                                            <TextBlock Text="Temps moyens de fabrication"/>
                                        </ChartTitle>
                                        <PlotArea >
                                            <XAxis  MinValue="0" Step="1" LayoutMode="Between" AutoScale="True" >
                                                <AxisLabel><TextBlock Text="Temps de fabrication (en minutes)"></TextBlock></AxisLabel>   
                                            </XAxis>
                                            <YAxis MaxValue="2"  Step="0.25" AxisMode="Extended">
                                                <AxisLabel><TextBlock Text="Fréquence"></TextBlock></AxisLabel>   
                                            </YAxis>
                                            <YAxis2 MaxValue="3" MinValue="0" Step="1"/>
                                        </PlotArea>
                                    </telerik:RadChart>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
 
            </MasterTableView>
        </telerik:RadGrid>

This is my ASPNET code. I've put the c# code you gave me but e.Item.OwnerTableView.Name is always "" (null).
0
Princy
Top achievements
Rank 2
answered on 14 May 2012, 11:47 AM
Hi Vincent,

I am not quiet sure about your requirement. I guess you want to access the RadChart in the ItemDataBound event. I don't understand the way you are binding the GridTableView. If you are binding it in code behind and the HierarchyLoadMode is ServerOnDemand (default) then DataBind of a child GridTableView would only take place when an item is Expanded.If you want to access the RadChart before the item is expanded, please set the HierarchyLoadMode to Client/ServerBind. Please take a look into this documentation for more information.

Please provide the way you are binding the GridTableView, if this does'nt help.

Thanks,
Princy.
Tags
Grid
Asked by
charles
Top achievements
Rank 1
Answers by
Vincent
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or