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

collapse/expand issues

3 Answers 57 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 25 Mar 2015, 06:42 PM
Please explain me how to troubleshoot following issue: 
I'm using NeedDataSource event to bind list
protected void RadTreeList2_NeedDataSource(object source, TreeListNeedDataSourceEventArgs e)
{
    DataTable dt = GetDataTable();
    RadTreeList2.DataSource = dt; 
}

In function GetDataTable() two options available:
Option 1 - get data table from execution of database request 
DataTable table = objController.GetMessages();

Option 2: Build table 'manually'
DataTable table = new DataTable();
table.Columns.Add("SubjectId", typeof(string));
table.Columns.Add("Subject", typeof(string));
table.Columns.Add("UserName", typeof(string));
table.Columns.Add("Status", typeof(string));
table.Columns.Add("Message", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
table.Columns.Add("Related", typeof(string));

table.Rows.Add("e6628832-54c7-4b18-ad2e-290065bc56c3", "Subject1D", "Sent", "User1", "Body1", DateTime.Now, "");
table.Rows.Add("e6628832-54c7-4b18-ad2e-290065bc56c3", "Subject1D", "Received", "User1", "Body2", DateTime.Now, "e6628832-54c7-4b18-ad2e-290065bc56c3");

table.Rows.Add("e6628832-54ca-4b18-ad2e-290065bc56c3", "Subject2D", "Sent", "User1", "Body3", DateTime.Now, "");
table.Rows.Add("e6628832-54ca-4b18-ad2e-290065bc56c3", "Subject2D", "Received", "User1", "Body4", DateTime.Now, "e6628832-54ca-4b18-ad2e-290065bc56c3");

Both options return the same table (I compared) and show the same information in the list.
The problem is when I using Option 1, collapse/expand is not working either manually (clicking +) not programmatecally. No errors/exception fired.
This is internal RadTreeList  - not sure how to find reason for such behavior.

HTML/aspx looks like:

<telerik:RadSkinManager ID="QsfSkinManager" Skin="Default" runat="server" ShowChooser="false" />
 <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
 <telerik:RadProgressManager runat="server" ID="RadProgressManager1" />      <div class="demo-containers">
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" MinDisplayTime="0"></telerik:RadAjaxLoadingPanel>
        <div class="demo-container">
            <h2 class="qsfSubtitle">Messages History</h2>
 <telerik:RadAjaxPanel ID="RadAjaxPanel3" LoadingPanelID="RadAjaxLoadingPanel1" runat="server">
                <telerik:RadTreeList runat="server" ID="RadTreeList2" AllowPaging="true" PageSize="5" DataKeyNames="SubjectId" ParentDataKeyNames="Related" OnNeedDataSource="RadTreeList2_NeedDataSource"
                AutoGenerateColumns="false" OnDeleteCommand="RadTreeList2_DeleteCommand"  OnItemCommand="RadTreeList2_ItemCommand"
     OnUpdateCommand="RadTreeList2_UpdateCommand" >
    <ClientSettings>
                    <ClientEvents OnItemContextMenu="demo.onItemContextMenu"  OnItemDblClick="demo.OnItemDblClick" OnItemClick="demo.OnItemClick"></ClientEvents>
                    <Selecting AllowItemSelection="True"></Selecting>
                </ClientSettings>
                <Columns>
                   <telerik:TreeListBoundColumn DataField="SubjectId" HeaderText="SubjectId" UniqueName="SubjectId">
      <ItemStyle VerticalAlign="Middle" HorizontalAlign="Left" Width="5%"/>
      <HeaderStyle HorizontalAlign="Left" Width="5%" />
     </telerik:TreeListBoundColumn>
                    <telerik:TreeListBoundColumn DataField="Subject" HeaderText="Subject" UniqueName="Subject">
      <ItemStyle VerticalAlign="Middle" HorizontalAlign="Left" Width="15%"/>
      <HeaderStyle HorizontalAlign="Left" Width="15%" />
     </telerik:TreeListBoundColumn>
                    <telerik:TreeListBoundColumn DataField="UserName" HeaderText="UserName" UniqueName="UserName">
      <ItemStyle VerticalAlign="Middle" HorizontalAlign="Left" Width="15%"/>
      <HeaderStyle HorizontalAlign="Left" Width="15%" />
     </telerik:TreeListBoundColumn>
                    <telerik:TreeListBoundColumn DataField="Status" HeaderText="Status" UniqueName="Status">
      <ItemStyle VerticalAlign="Middle" HorizontalAlign="Left" Width="10%"/>
      <HeaderStyle HorizontalAlign="Left" Width="10%" />
     </telerik:TreeListBoundColumn>
      <telerik:TreeListTemplateColumn HeaderText="Message" SortExpression="Message" UniqueName="Message">
             <ItemTemplate>
                <asp:Label runat="server" ID="lblStatus" Text='<%# Eval("Message") %>' ToolTip='<%# Eval("Message") %>'/>
             </ItemTemplate>
             <ItemStyle VerticalAlign="Middle" HorizontalAlign="Left" Width="40%" Wrap = "False" />
             <HeaderStyle HorizontalAlign="Left" Width="40%" />
         </telerik:TreeListTemplateColumn>
                    <telerik:TreeListBoundColumn DataField="Date" HeaderText="Date" UniqueName="Date">
      <ItemStyle VerticalAlign="Middle" HorizontalAlign="Left" Width="15%"/>
      <HeaderStyle HorizontalAlign="Left" Width="15%" />
     </telerik:TreeListBoundColumn>
                    <telerik:TreeListBoundColumn DataField="Related" HeaderText="Related" UniqueName="Related"></telerik:TreeListBoundColumn>
                </Columns>
                <EditFormSettings EditFormType="Template" PopUpSettings-Width="600px">
                <FormTemplate>
                    <div class="editTemplate">
                        <table>
                            <tr class="EditFormHeader">
                                <td colspan="2" style="font-size: small">
                                    <b>Reply:</b>
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top">
                                    <table class="module">
                                        <tr>
                                            <td colspan = "2">
                                                <asp:TextBox ID="txtMsg" TextMode = "MultiLine" Height = "100" Width = "300" Text='<%# Eval("Message", "\n >>>>\n {0} ") %>'  runat="server">
                                                </asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <telerik:RadButton ID= "btnSend" Text = "Send" CommandName = "Update" Icon-PrimaryIconCssClass="rbOk" runat="server"/>                                            </td>
                                            <td>
                                                <telerik:RadButton ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                                                CommandName="Cancel" Icon-PrimaryIconCssClass="rbCancel" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                             </tr>
                        </table>
                     </div>
                </FormTemplate>
                </EditFormSettings>
                 </telerik:RadTreeList>
     <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" RelativeTo="Mouse"
     Position="MiddleRight" AutoTooltipify="false" ContentScrolling="Default" Width="50"
     Height="10" />
                <telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnClientItemClicked="demo.onClientItemClicked">
                <Items>
                    <telerik:RadMenuItem Text="Reply" Value="Edit"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Delete" Value="Delete"></telerik:RadMenuItem>
                </Items>
                </telerik:RadContextMenu>
            </telerik:RadAjaxPanel>
        </div>
    </div>

Thanks you,
Boris








 

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 30 Mar 2015, 10:36 AM
Hello Boris,

This behavior is pretty strange but you can disable the ajax and check whether sample will thrown an server exception. If no exception is thrown could you please sent your GetDataTable method which retrieves the datasource.

Regards,
Kostadin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Boris
Top achievements
Rank 1
answered on 13 Apr 2015, 03:32 PM

Hello Kostadin,

thank you for the reply. I have found problem with exception fired when NeedDataSource event called 2nd time at Expand.

For some reasons I thought that this event won't be fired with expand/collapse since control already have all information required in the memory, but it does fire event.

Thanks,

Boris

0
Kostadin
Telerik team
answered on 16 Apr 2015, 08:48 AM
Hi Boris,

Note that there is a different hierarchy load modes which behaves differently. I would recommend you to examine the following help article which describes all of them and use the one which fulfill your requirement.

Regards,
Kostadin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
TreeList
Asked by
Boris
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Boris
Top achievements
Rank 1
Share this question
or