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

TreeList disappears after clicking expand

3 Answers 112 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 18 Oct 2012, 05:40 PM

I have a TreeList that loads onclick of a button (btnGeoDetailsFacilities) which calls RadGeoTreeListFacilities_Bind() this function grabs the parents. All of that works fine, I get parent rows.

Problem:

The problem is when I click the expand node the Treelist and headers disappear and no event is called. If I click the “btnGeoDetailsFacilities” button a second time RadTreeList1_ChildItemsDataBind is called and the grid loads with child items expanded as it should have when I clicked the expand button.

Question:

Why are the Tree and headers disappearing on expand and how do I get it to work properly e.g. show children when I click expand? As show here http://demos.telerik.com/aspnet-ajax/treelist/examples/databinding/loadondemand/defaultvb.aspx

Code:

<telerik:RadAjaxPanelID="RadAjaxPanel1"LoadingPanelID="RadAjaxLoadingPanel"runat="server">

            <telerik:RadTreeListrunat="server"ID="RadGeoTreeList"Visible="true"DataKeyNames="FacilitiesreportingId"ParentDataKeyNames="VERA3"AutoGenerateColumns="false"

            Width="100%"Height="400"ShowTreeLines="true"AllowLoadOnDemand="true">

                <Columns>

                    <telerik:TreeListBoundColumnDataField="Origin"HeaderText="Origin"UniqueName="Origin"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="Destination"HeaderText="Destination"UniqueName="Destination"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="FinanceNumber"HeaderText="Finance Number"UniqueName="FinanceNumber"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="Address"HeaderText="Address"UniqueName="Address"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="City"HeaderText="City"UniqueName="City"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="State"HeaderText="State"UniqueName="State"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="ZipCode"HeaderText="Zip"UniqueName="ZipCode"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="Distance"HeaderText="Driving Distance"UniqueName="Distance"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="Area"HeaderText="Area"UniqueName="Area"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="PFC"HeaderText="PFC"UniqueName="PFC"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="OnRolls1"HeaderText="OnRolls"UniqueName="OnRolls1"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="Residual"HeaderText="Residual"UniqueName="Residual"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="Withheld"HeaderText="Withheld"UniqueName="Withheld"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="Optional1"HeaderText="OPT"UniqueName="Optional1"></telerik:TreeListBoundColumn>

                    <telerik:TreeListBoundColumnDataField="VERA1"HeaderText="VER"UniqueName="VERA1"></telerik:TreeListBoundColumn>

                </Columns>

            </telerik:RadTreeList>

        </telerik:RadAjaxPanel>

        <telerik:RadAjaxLoadingPanelID="RadAjaxLoadingPanel"runat="server"/>

 

<telerik:RadAjaxManagerrunat="server"ID="RadAjaxManager1"ClientEvents-OnRequestStart="mngRequestStarted"EnableAJAX="true">

              <AjaxSettings>

            <telerik:AjaxSettingAjaxControlID="btnGeoDetailsFacilities">

                           <UpdatedControls>

                    <telerik:AjaxUpdatedControlControlID="RadGeoTreeList"LoadingPanelID="RadAjaxLoadingPanel"/>

                           </UpdatedControls>

                     </telerik:AjaxSetting>

</AjaxSettings>

              <ClientEventsOnRequestStart="mngRequestStarted"/>

       </telerik:RadAjaxManager>

 

 

 

PublicSub RadGeoTreeListFacilities_Bind()

 

        geoDataList = ds.GetDistanceGridFacilities(oLat, oLon, radius, facilityNumber)

 

        Dim g = (From item In geoDataList _

                Where item.VERA3 = Nothing _

                Select item).ToList()

 

        RadGeoTreeList.DataSource = g

        Cache("geoData") = geoDataList

    EndSub

 

‘why does this get called twice onload?

ProtectedSub RadTreeList1_NeedDataSource(ByVal sender AsObject, ByVal e AsTreeListNeedDataSourceEventArgs) Handles RadGeoTreeList.NeedDataSource

        If IsCallback Or IsPostBack Then

            If Session("GeoTreeListMode") = "facilities"Then

                RadGeoTreeListFacilities_Bind()

            ElseIf Session("GeoTreeListMode") = "studies"Then

                RadGeoTreeList_Bind()

            EndIf

        EndIf

    EndSub

 

ProtectedSub RadTreeList1_ChildItemsDataBind(ByVal sender AsObject, ByVal e AsTreeListChildItemsDataBindEventArgs) Handles RadGeoTreeList.ChildItemsDataBind

        Dim id AsInteger = Convert.ToInt32(e.ParentDataKeyValues("FacilitiesreportingId").ToString())

 

        Dim g = (From item In geoDataList _

                Where item.VERA3 = id _

                Select item).ToList()

 

        e.ChildItemsDataSource = g

    EndSub

 

ProtectedSub OnClick_btnGeoDetailsFacilities(sender AsObject, e As System.EventArgs)

        Session("GeoTreeListMode") = "facilities"

End Sub

 

 

PublicClassFacilityItem

    Private _Origin AsString

    PublicProperty Origin() AsString

        Get

            Return _Origin

        EndGet

        Set(ByVal value AsString)

            _Origin = value

        EndSet

    EndProperty

 

    Private _Destination AsString

    PublicProperty Destination() AsString

        Get

            Return _Destination

        EndGet

        Set(ByVal value AsString)

            _Destination = value

        EndSet

    EndProperty

 

    Private _Distance AsString

    PublicProperty Distance() AsString

        Get

            Return _Distance

        EndGet

        Set(ByVal value AsString)

            _Distance = value

        EndSet

    EndProperty

 

 

    Private _Address AsString

    PublicProperty Address() AsString

        Get

            Return _Address

        EndGet

        Set(ByVal value AsString)

            _Address = value

        EndSet

    EndProperty

 

    Private _City AsString

    PublicProperty City() AsString

        Get

            Return _City

        EndGet

        Set(ByVal value AsString)

            _City = value

        EndSet

    EndProperty

 

    Private _State AsString

    PublicProperty State() AsString

        Get

            Return _State

        EndGet

        Set(ByVal value AsString)

            _State = value

        EndSet

    EndProperty

 

    Private _ZipCode AsString

    PublicProperty ZipCode() AsString

        Get

            Return _ZipCode

        EndGet

        Set(ByVal value AsString)

            _ZipCode = value

        EndSet

    EndProperty

 

    Private _FinanceNumber AsString

    PublicProperty FinanceNumber() AsString

        Get

            Return _FinanceNumber

        EndGet

        Set(ByVal value AsString)

            _FinanceNumber = value

        EndSet

    EndProperty

 

    Private _FacilityName AsString

    PublicProperty FacilityName() AsString

        Get

            Return _FacilityName

        EndGet

        Set(ByVal value AsString)

            _FacilityName = value

        EndSet

    EndProperty

 

 

    Private _Optional1 AsInteger

    PublicProperty Optional1() AsInteger

        Get

            Return _Optional1

        EndGet

        Set(ByVal value AsInteger)

            _Optional1 = value

        EndSet

    EndProperty

 

    Private _Withheld AsInteger

    PublicProperty Withheld() AsInteger

        Get

            Return _Withheld

        EndGet

        Set(ByVal value AsInteger)

            _Withheld = value

        EndSet

    EndProperty

 

    Private _OnRolls1 AsInteger

    PublicProperty OnRolls1() AsInteger

        Get

            Return _OnRolls1

        EndGet

        Set(ByVal value AsInteger)

            _OnRolls1 = value

        EndSet

    EndProperty

 

    Private _Area AsString

    PublicProperty Area() AsString

        Get

            Return _Area

        EndGet

        Set(ByVal value AsString)

            _Area = value

        EndSet

    EndProperty

 

    Private _PFC AsString

    PublicProperty PFC() AsString

        Get

            Return _PFC

        EndGet

        Set(ByVal value AsString)

            _PFC = value

        EndSet

    EndProperty

 

    Private _Residual AsInteger

    PublicProperty Residual() AsInteger

        Get

            Return _Residual

        EndGet

        Set(ByVal value AsInteger)

            _Residual = value

        EndSet

    EndProperty

 

    Private _FacilitiesreportingId AsInteger

    PublicProperty FacilitiesreportingId() AsInteger

        Get

            Return _FacilitiesreportingId

        EndGet

        Set(ByVal value AsInteger)

            _FacilitiesreportingId = value

        EndSet

    EndProperty

 

    Private _VERA1 AsInteger

    PublicProperty VERA1() AsInteger

        Get

            Return _VERA1

        EndGet

        Set(ByVal value AsInteger)

            _VERA1 = value

        EndSet

    EndProperty

 

    Private _VERA3 AsInteger

    PublicProperty VERA3() AsInteger

        Get

            Return _VERA3

        EndGet

        Set(ByVal value AsInteger)

            _VERA3 = value

        EndSet

    EndProperty

 

    'Public Sub New(ByVal strOrigin As String, ByVal strDestination As String, ByVal strCity As String, ByVal strState As String, ByVal strZipCode As String, ByVal strAddress As String, _

    '               ByVal strDistance As String, ByVal strFacilityName As String, ByVal strFinanceNumber As String, ByVal strArea As String, ByVal strPFC As String, ByVal intOnRolls1 As Integer, _

    '               ByVal intVERA1 As Integer, ByVal intResidual As Integer, ByVal intOptional1 As Integer, ByVal intWithHeld As Integer, ByVal intFacilitiesreportingId As Integer, ByVal intVERA3 As Integer)

 

    '    Origin = strOrigin

    '    Destination = strDestination

    '    City = strCity

    '    State = strState

    '    ZipCode = strZipCode

    '    Address = strAddress

    '    Distance = strDistance

    '    FacilityName = strFacilityName

    '    FinanceNumber = strFinanceNumber

    '    Area = strArea

    '    PFC = strPFC

    '    OnRolls1 = intOnRolls1

    '    VERA1 = intVERA1

    '    VERA3 = intVERA3

    '    Residual = intResidual

    '    Optional1 = intOptional1

    '    FacilitiesreportingId = intFacilitiesreportingId

    '    Withheld = intWithHeld

    'End Sub

 

 

End Class

 

 

Mock data:

'mergedList.Add(New FacilityItem("asdf", "asdf", "asdf", "asdf", "asdf", "asdf", "asdf", "asdf", "asdf", "asdf", "asdf", 1234, 1234, 1234, 1234, 1234, 222, 1))

        'mergedList.Add(New FacilityItem("header", "header", "header", "header", "header", "header", "header", "header", "header", "header", "header", 1234, 1234, 1234, 1234, 1234, 1, 0))

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 23 Oct 2012, 08:35 AM
Hi,

 It seems the problem is in the way you bind the control. You should allow the code in the NeedDataSource event to run always and not only on Postback. Also in the OnClick_btnGeoDetailsFacilities handler you should call the Rebind method which will force the control to call the NeedDataSource event and bind as expected. The important part is to always have a datasource assigned to the control before rebinding it so that the all the data can be displayed correctly.

All the best,
Marin
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
Doug Hills
Top achievements
Rank 1
answered on 30 Oct 2012, 08:16 PM
I am having the same problem as well. I have viewstate turned on and I populate the tree at the initial page load.

Why would I have to re-bind the listTree at row expansion? Should not all of the necessary data be hooked onto the listTree?

And it seems like you've missed an opportunity here to have a load once scenario with expansions and collapses occurring on the client only. Same for a hierarchical application of the radGrid.

Doug
0
Marin
Telerik team
answered on 01 Nov 2012, 08:15 AM
Hello,

 If you use the NeedDataSource event to bind the control it will automatically retrieve the needed data when you expand / collapse otherwise you will have to rebind the control on every operation because it will not extract the new data automatically.

Regards,
Marin
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
TreeList
Asked by
Justin
Top achievements
Rank 1
Answers by
Marin
Telerik team
Doug Hills
Top achievements
Rank 1
Share this question
or