Help with heirachial grid

2 posts, 0 answers
  1. EmpowerIT
    EmpowerIT avatar
    117 posts
    Member since:
    Jun 2007

    Posted 16 Jan 2008 Link to this post

    I'm trying to do populate a radgrid using sqldatasource. There are three levels to the grid.

    The top level can be populated using one of two different datasources. The other two levels always have their datasources fixed.

    The top level datasources will return the exact same fields (the only difference is in their select statement).

    I've tried doing this:
    1  void ScheduleDetailView_Load(object sender, EventArgs e) 
    2     { 
    3         string typeID = Request["typeId"]; 
    4         if ( typeID == "1"
    5         { 
    6             RadGrid1.MasterTableView.DataSourceID = "JobsSourceSuburb"
    7         } 
    8         else 
    9         { 
    10             RadGrid1.MasterTableView.DataSourceID = "JobsSourceTech"
    11         } 
    12     } 

    The data binds correctly, however it does not let me expand down to the other levels of the grid. If i hardcode the DataSourceId for the masterview table into the aspx it works fine.

    My RadGrid definition is below:

    1      <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Web20" AllowSorting="True" DataSourceID="JobsSourceTech" GridLines="None" AutoGenerateColumns="False" AutoGenerateEditColumn="True" AllowAutomaticUpdates="True"
    2     <GroupPanel ID="GroupPanel" Style="width: 100%;"
    3     </GroupPanel> 
    4     <ExportSettings> 
    5         <Pdf FontType="Subset" PaperSize="Letter" /> 
    6         <Excel Format="Html" /> 
    7     </ExportSettings> 
    8     <MasterTableView CommandItemDisplay="None" CurrentResetPageIndexAction="SetPageIndexToFirst" DataKeyNames="JobId" 
    9          Dir="LTR" Frame="Border" TableLayout="Auto" AllowAutomaticUpdates="true" EditMode="InPlace"
    10         <EditFormSettings> 
    11             <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
    12             </EditColumn> 
    13         </EditFormSettings> 
    14         <ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    15             Resizable="False"
    16             <HeaderStyle Width="20px" /> 
    17         </ExpandCollapseColumn> 
    18         <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    19             Visible="False"
    20             <HeaderStyle Width="20px" /> 
    21         </RowIndicatorColumn> 
    22         <Columns> 
    23             <telerik:GridEditCommandColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    24                 UniqueName="AutoGeneratedEditColumn"
    25                 <HeaderStyle Width="30px" /> 
    26             </telerik:GridEditCommandColumn> 
    27             <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="OrderNumber" 
    28                 FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Order Number" 
    29                 ReadOnly="True" UniqueName="OrderNumber"
    30             </telerik:GridBoundColumn> 
    31             <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="AccountName" 
    32                 FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Account" 
    33                 ReadOnly="True" UniqueName="Account Name"
    34             </telerik:GridBoundColumn> 
    35             <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    36                 ForceExtractValue="None" HeaderText="Address" SortExpression="Address" UniqueName="column" DataField="Address" ReadOnly="True"
    37             </telerik:GridBoundColumn> 
    38             <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Suburb" FilterListOptions="VaryByDataType" 
    39                 ForceExtractValue="None" HeaderText="Suburb" ReadOnly="True" UniqueName="Suburb"
    40             </telerik:GridBoundColumn> 
    41             <telerik:GridCheckBoxColumn CurrentFilterFunction="NoFilter" DataField="Vacant" FilterListOptions="VaryByDataType" 
    42                 ForceExtractValue="None" HeaderText="Vacant" SortExpression="Vacant" UniqueName="Vacant"
    43                 </telerik:GridCheckBoxColumn> 
    44                         <telerik:GridCheckBoxColumn CurrentFilterFunction="NoFilter" DataField="Recall" FilterListOptions="VaryByDataType" 
    45                 ForceExtractValue="None" HeaderText="Recall" SortExpression="Recall" UniqueName="Recall"
    46                 </telerik:GridCheckBoxColumn> 
    47                   <telerik:GridCheckBoxColumn CurrentFilterFunction="NoFilter" DataField="Confirmed" FilterListOptions="VaryByDataType" 
    48                 ForceExtractValue="None" HeaderText="Confirmed" SortExpression="Confirmed" UniqueName="Confirmed"
    49                 </telerik:GridCheckBoxColumn> 
    50             <telerik:GridDateTimeColumn ReadOnly="True" CurrentFilterFunction="NoFilter" DataField="DueDateTime" FilterListOptions="VaryByDataType" 
    51                 ForceExtractValue="None" HeaderText="Due Date" SortExpression="DueDateTime" UniqueName="DueDateTime" DataType="System.DateTime"  DataFormatString="{0:d}"
    52                 </telerik:GridDateTimeColumn> 
    53         </Columns> 
    54         <DetailTables> 
    55             <telerik:GridTableView runat="server" CommandItemDisplay="None" 
    56                 CurrentResetPageIndexAction="SetPageIndexToFirst" DataKeyNames="JobId,JobCodeId" DataSourceID="JobCodesSource" 
    57                 Dir="LTR" Frame="Border" TableLayout="Auto"
    58                 <EditFormSettings> 
    59                     <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
    60                     </EditColumn> 
    61                 </EditFormSettings> 
    62                 <ParentTableRelation> 
    63                     <telerik:GridRelationFields DetailKeyField="JobId" MasterKeyField="JobId" /> 
    64                 </ParentTableRelation> 
    65                 <ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    66                     Resizable="False"
    67                     <HeaderStyle Width="20px" /> 
    68                 </ExpandCollapseColumn> 
    69                 <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    70                     Visible="False"
    71                     <HeaderStyle Width="20px" /> 
    72                 </RowIndicatorColumn> 
    73                 <Columns> 
    74                 <telerik:GridDropDownColumn DataField="CodeId" DataSourceID="CodeSource" ListTextField="CodeName"  
    75                             ListValueField="CodeId" HeaderText="Code" UniqueName="CodeId" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" ForceExtractValue="None"
    76                      </telerik:GridDropDownColumn> 
    77  
    78                    <telerik:GridNumericColumn CurrentFilterFunction="NoFilter" DataField="QuantityRequired" 
    79                         DataType="System.Decimal" FilterListOptions="VaryByDataType" ForceExtractValue="None" 
    80                         HeaderText="QuantityRequired" SortExpression="QuantityRequired" UniqueName="QuantityRequired" NumericType="Number"</telerik:GridNumericColumn> 
    81                      
    82                     <telerik:GridNumericColumn CurrentFilterFunction="NoFilter" DataField="QuantityCompleted" 
    83                         DataType="System.Decimal" FilterListOptions="VaryByDataType" ForceExtractValue="None" 
    84                         HeaderText="QuantityCompleted" SortExpression="QuantityCompleted" UniqueName="QuantityCompleted" NumericType="Number"
    85                         </telerik:GridNumericColumn>  
    86                     <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Comment" FilterListOptions="VaryByDataType" 
    87                         ForceExtractValue="None" HeaderText="Comment" SortExpression="Comment" UniqueName="Comment"
    88                     </telerik:GridBoundColumn>          
    89                 </Columns> 
    90                 <DetailTables> 
    91                     <telerik:GridTableView runat="server" CommandItemDisplay="None" CurrentResetPageIndexAction="SetPageIndexToFirst" 
    92                         DataSourceID="JobScheduleSource" DataKeyNames="JobCodeId,ScheduleId" Dir="LTR" Frame="Border" TableLayout="Auto"
    93                         <EditFormSettings> 
    94                             <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
    95                             </EditColumn> 
    96                         </EditFormSettings> 
    97                          <ParentTableRelation> 
    98                             <telerik:GridRelationFields DetailKeyField="JobCodeId" MasterKeyField="JobCodeId" /> 
    99                         </ParentTableRelation> 
    100                         <ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    101                             Resizable="False" Visible="False"
    102                             <HeaderStyle Width="20px" /> 
    103                         </ExpandCollapseColumn> 
    104                         <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
    105                             Visible="False"
    106                             <HeaderStyle Width="20px" /> 
    107                         </RowIndicatorColumn> 
    108                         <Columns> 
    109                             <telerik:GridDateTimeColumn CurrentFilterFunction="NoFilter" DataField="ScheduleDateTime" 
    110                                 DataType="System.DateTime" FilterListOptions="VaryByDataType" ForceExtractValue="None" 
    111                                 HeaderText="Schedule Date/Time" UniqueName="ScheduleDateTime" PickerType="DateTimePicker"
    112                             </telerik:GridDateTimeColumn> 
    113                             <telerik:GridDropDownColumn DataField="TechnicianId" DataSourceID="TechniciansSource" ListTextField="TechName"  
    114                             ListValueField="TechnicianId" HeaderText="Technician" UniqueName="TechnicianId" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" ForceExtractValue="None"
    115                             </telerik:GridDropDownColumn> 
    116                             <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="ScheduleNote" 
    117                                 FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Notes" 
    118                                 MaxLength="200" UniqueName="ScheduleNote"
    119                             </telerik:GridBoundColumn> 
    120                         </Columns> 
    121                     </telerik:GridTableView> 
    122                 </DetailTables> 
    123             </telerik:GridTableView> 
    124         </DetailTables> 
    125     </MasterTableView> 
    126 </telerik:RadGrid> 

    Any help would be appreciated,

    Fayez
  2. EmpowerIT
    EmpowerIT avatar
    117 posts
    Member since:
    Jun 2007

    Posted 16 Jan 2008 Link to this post

    I fixed the problem, i removed that code from the Load event and added it to the NeedDataSource event ... seems quite obvious now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top