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

Hierarchical Grid, binding problem

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jean-Marc
Top achievements
Rank 1
Jean-Marc asked on 30 Sep 2011, 04:40 PM
I can not find the problem out.
Hierarchical Grid, autogenerated column, datasource from my business object.
Here is the code
<telerik:RadGrid    ID="RadGridTableau"
                           runat="server"
                           GridLines="Vertical"
                           AllowPaging="true"
                           allowsorting="true"
                           Skin="Simple"
                           AllowFilteringByColumn="False"
                           AutoGenerateColumns="True"                                   
                           PageSize="10"
                           Width="1500"                                                                      
                           >
                                                                    
       <MasterTableView    NoMasterRecordsText="Nessun Tableau presente."
                           GridLines="Vertical"
                           AllowPaging="true"
                           AllowFilteringByColumn="False"
                           TableLayout="Fixed"
                           Name="TableauMain"
                           DataKeyNames="idTypology"
                           >
 
 
            <DetailTables>
               <telerik:GridTableView DataKeyNames="idRisorsa" Name="TableauDetail" AutoGenerateColumns="true">
                   <Columns>
                                                        
                   </Columns>
               </telerik:GridTableView>
           </DetailTables>
              
           <Columns>
             </Columns>
                                                               
       </MasterTableView>
        
       <ClientSettings enablePostBackOnRowClick="true" >
           <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>
           <Selecting AllowRowSelect="True" />
       </ClientSettings>
            
   </telerik:RadGrid>   

Protected Sub RadGridTableau_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles RadGridTableau.DetailTableDataBind
        Try
 
            Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
            Dim idTypology As String = dataItem.GetDataKeyValue("idTypology").ToString()
            Dim d1 As Date = RadDatePicker_From.SelectedDate
           Dim d2 As Date = RadDatePicker_To.SelectedDate
 
            Dim polInterface As New POL_Manager.CPolInterface(myConn)
            Dim myDatasource As DataSet = polInterface.StateResources(idTypology, d1, d2, AvailableState)
 
            LogManager.WriteToDebugLog("c:\log\aa\", "RadGridTableau_DetailTableDataBind myDatasource.Tables(0).Columns.Count " & myDatasource.Tables(0).Columns.Count)
 
            e.DetailTableView.DataSource = myDatasource
            'e.DetailTableView.ShowHeader = False 
 
        Catch ex As Exception
            Call LogManager.WriteToErrorLog(errorPath, ClassName, System.Reflection.MethodBase.GetCurrentMethod.Name.ToString(), ex, Err())
        End Try
    End Sub


I have a simple button too, it is used to rebind grid with different values for the business object datasource (polInterface.StateResources(idTypology, d1, d2, AvailableState) ) d1 and d2 are here different then first time
<asp:Button ID="btnRebind" runat="server" Text="Reload" />
Protected Sub btnRebind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRebind.Click
        Try
            RadGridTableau.Rebind()
 
            For Each item As GridDataItem In RadGridTableau.MasterTableView.Items
                For Each innerView As GridTableView In item.ChildItem.NestedTableViews
                    innerView.DataSource = Nothing
                    innerView.Rebind()
                Next
            Next
        Catch ex As Exception
            Call LogManager.WriteToErrorLog(errorPath, ClassName, System.Reflection.MethodBase.GetCurrentMethod.Name.ToString(), ex, Err)
        End Try
    End Sub


For example:
at the beginning d1=today d2=dateadd("m",1,today) everything ok
I change d1 and d2, press reload button. RadGridTableau_DetailTableDataBind is invoked.
Mastertableaview is correct, show colums and data for the changed period, innerviews still shows old data BUT
 myDatasource.Tables(0).Columns.Count)
tells me they are bound to the correct datasource (gives back coloumn count of new period).

So I first thought to an ajax problem. I removed all the ajax still does not work

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 03 Oct 2011, 12:48 PM
Hello Jean-Marc,

If I properly understand you expect to have different set of column in the detail tables between the rebinds, right? However this is not supported with hierarchy built with DetailTables, because once built their columns structure cannot be changed. In your case you can try building the hierarchy with NestedViewTemplate with another RadGrid inside.

Greetings,
Iana Tsolova
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
Jean-Marc
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or