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

[Solved] Problem with Grid using ExpandCollapseColumn

1 Answer 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nikola
Top achievements
Rank 2
Nikola asked on 19 Mar 2013, 12:57 PM
Hey

Story:

I using RadGrid with ExpandCollapseColumn and I want to show for every user his Departments + Leader if you click on a departments it is Expanding and you can see the members of the departments  click on one user and again the column is Expanding then you can see from date to date the working time in % and his vacation days so far its working 


Problem:

In the last step when I want to show the specific from date to date the working time in % etc... it not working I have know for testing inserted that only one user in a specific department has from date to date the working time in % etc.. and so the  problem is IT is displaying it to every user it doesn't meter if he has inserted from date to date the working time in % etc.. or not ..
<asp:Content ID="Content1" ContentPlaceHolderID="MainRegionContentPlaceHolder" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="DepEmpGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="DepEmpGrid"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadGrid ID="DepEmpGrid" OnPreRender="DepEmpGrid_PreRender" ShowStatusBar="True" DataSourceID="LeaderViewSQL" runat="server" AutoGenerateColumns="False"
        AllowSorting="True" AllowPaging="True" GridLines="None" CellSpacing="0" OnNeedDataSource="DepEmpGrid_NeedDataSource" >
        <PagerStyle Mode="NumericPages" />
        <MasterTableView DataKeyNames="DepartmentId" DataSourceID="LeaderViewSQL" AllowMultiColumnSorting="true"  ExpandCollapseColumn-CollapseImageUrl="~/Image/SingleMinus.gif" ExpandCollapseColumn-ExpandImageUrl="~/Image/SinglePlus.gif">
            <DetailTables>
                <telerik:GridTableView DataKeyNames="UserId" DataSourceID="DepartmentSQL" Width="100%" runat="server">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="DepartmentId" MasterKeyField="DepartmentId" />
                    </ParentTableRelation>
                    <DetailTables>
                        <telerik:GridTableView DataKeyNames="AnnualVacationId" DataSourceID="AnnualVacationSQL" Width="100%" runat="server">
                            <ParentTableRelation>
                                <telerik:GridRelationFields DetailKeyField="UserId" MasterKeyField="UserId" />
                            </ParentTableRelation>
                            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
 
                            <Columns>
                                <telerik:GridBoundColumn SortExpression="FromDate" HeaderText="From date" HeaderButtonType="TextButton" DataField="FromDate" UniqueName="FromDate" DataFormatString="{0:dd/MM/yyyy}"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="ToDate" HeaderText="To date" HeaderButtonType="TextButton" DataField="ToDate" UniqueName="ToDate" DataFormatString="{0:dd/MM/yyyy}"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="WorkingTime" HeaderText="Working time in %" HeaderButtonType="TextButton" DataField="WorkingTime" UniqueName="WorkingTime"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="VacationDays" HeaderText="Vacation days" HeaderButtonType="TextButton" DataField="VacationDays" UniqueName="VacationDays"></telerik:GridBoundColumn>
                            </Columns>
                            <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                            </EditFormSettings>
                        </telerik:GridTableView>
                    </DetailTables>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                     
                    <Columns>
                        <telerik:GridBoundColumn SortExpression="Name" HeaderText="Name" HeaderButtonType="TextButton" DataField="Name" UniqueName="Name"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn SortExpression="Email" HeaderText="Email" HeaderButtonType="TextButton" DataField="Email" UniqueName="Email"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn SortExpression="AdDomain" HeaderText="AdDomain" HeaderButtonType="TextButton" DataField="AdDomain" UniqueName="AdDomain" Visible="false"></telerik:GridBoundColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                    </EditFormSettings>
                </telerik:GridTableView>
            </DetailTables>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn SortExpression="DepartmentName" HeaderText="DepartmentName" DataField="DepartmentName" UniqueName="DepartmentName"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="Leader" HeaderText="Leader" DataField="Leader" UniqueName="Leader"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="DepartmentId" DataType="System.Int32" FilterControlAltText="Filter DepartmentId column" HeaderText="DepartmentId" SortExpression="DepartmentId" UniqueName="DepartmentId" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UserId" DataType="System.Int32" FilterControlAltText="Filter UserId column" HeaderText="UserId" SortExpression="UserId" UniqueName="UserId" Visible="false">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
 
 
    <asp:SqlDataSource ID="LeaderViewSQL" runat="server" ConnectionString="<%$ ConnectionStrings:HolidayTrackerConnectionString %>"
        SelectCommand="SELECT * FROM [LeaderView]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="DepartmentSQL" runat="server" ConnectionString="<%$ ConnectionStrings:HolidayTrackerConnectionString %>"
        SelectCommand="SELECT * FROM [UserView] WHERE ([DepartmentId] = @DepartmentId)">
        <SelectParameters>
            <asp:SessionParameter Name="DepartmentId" SessionField="DepartmentId" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="AnnualVacationSQL" runat="server" ConnectionString="<%$ ConnectionStrings:HolidayTrackerConnectionString %>"
        SelectCommand="SELECT * FROM [AnnualVacation] WHERE UserId =@UserId">
        <SelectParameters>
            <asp:SessionParameter Name="UserId" SessionField="UserId" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>





Thanks for help and fast answer 

Feel free to ask if you need something more 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 23 Apr 2013, 02:39 PM
Hi Nikola,

I went through the provided code and I think that you have not configured the detail tables properly, therefore they show the same data, no matter which row is expanded. As I saw in the last datasource there is session parameter UserId, please check where you set it and what is its value. Then configure the declarative relations properly. For more information about ParentTableRelation you can refer to the help article below:
http://www.telerik.com/help/aspnet-ajax/grid-hierarchical-data-binding-using-declarative-relations.html

Kind regards,
Pavlina
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
Grid
Asked by
Nikola
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Share this question
or