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

RadGrid with two comboboxes in same row with data source of one depending on another selection

2 Answers 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Galina
Top achievements
Rank 1
Galina asked on 04 Jun 2018, 07:35 PM

I have RadGrid with EditMode="Batch". I have two columns Location and Department  and comboboxes Location and Department inside  EditItemTemplate and InsertItemTemplate. They use SqlDataSource, Location data source just query all the location records, department  data source has parameter - location id.

 

I need to be able to update data source of Department in edit and insert mode  depending on what is  selected in the column "location". I created hidden control that is used by department data source, but can't figure out when and how to set it to rebind the Department combobox.

 

Any help is greatly appreciated!

 <asp:HiddenField ID="hflocationid" runat="server" />

<telerik:RadGrid ID="RadGrid3" runat="server" DataSourceID="dsCatGroup" AllowAutomaticDeletes="true"
                        GroupPanelPosition="Top" ResolvedRenderMode="Classic" OnBatchEditCommand="RadGrid2_BatchEditCommand">
                        
                        <MasterTableView AutoGenerateColumns="False" DataKeyNames="PartCatGroupID" EditMode="Batch" CommandItemDisplay="Top"
                            DataSourceID="dsCatGroup" ShowHeadersWhenNoRecords="true">
                            <BatchEditingSettings EditType="Row"  />

                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="Responsible Location" UniqueName="ResponsibleLocation" DataField="ResponsibleLocation" HeaderStyle-Width="125px" AllowFiltering="true" ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="250px">
                                                <ItemTemplate>
                                                   <%# Eval("ResponsibleLocation")%>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                     <telerik:RadComboBox ID="ddResponsibleLocation1" Runat="server" DataSourceID="dsResponsibleLocations"
                                                                DataTextField="LocationName" DataValueField="LocationId" EmptyMessage="Select a Location"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>                       
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <telerik:RadComboBox ID="ddResponsibleLocation2" Runat="server" DataSourceID="dsResponsibleLocations"
                                                                DataTextField="LocationName" DataValueField="LocationId" EmptyMessage="Select a Location"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>
                                                                                 
                                                </InsertItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Responsible Department" UniqueName="ResponsibleDepartment" DataField="ResponsibleDepartment" HeaderStyle-Width="125px" AllowFiltering="true" ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="250px">
                                                <ItemTemplate>
                                                   <%# Eval("ResponsibleLocation")%>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                     <telerik:RadComboBox ID="ddResponsibleDepartment1" Runat="server" DataSourceID="dsResponsibleDepartments"
                                                                DataTextField="DepartmentCode" DataValueField="DepartmentId" EmptyMessage="Select a Department"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000" OnItemDataBound="ddResponsibleDepartment1_ItemDataBound"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>                       
                                                     
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <telerik:RadComboBox ID="ddResponsibleDepartment2" Runat="server" DataSourceID="dsResponsibleDepartments"
                                                                DataTextField="DepartmentCode" DataValueField="DepartmentId" EmptyMessage="Select a Department"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>
                                                </InsertItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridButtonColumn CommandName="Delete" ConfirmText="Are you sure you want to delete this Product Group?" ButtonType="ImageButton" HeaderText="Delete?" ConfirmDialogType="RadWindow" UniqueName="btnDeleteFinal">
                                        <ItemStyle VerticalAlign="Middle" />
                                <HeaderStyle Width="55px" />
                                </telerik:GridButtonColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>

 

<asp:SqlDataSource ID="dsResponsibleLocations" runat="server"
                        ConnectionString="<%$ ConnectionStrings:PPMTESTConnectionString %>"
                        SelectCommand="SELECT  [LocationId],[LocationName] FROM [PartCatLocations] ORDER BY [LocationName] ">
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="dsResponsibleDepartments" runat="server"
                        ConnectionString="<%$ ConnectionStrings:PPMTESTConnectionString %>"
                        SelectCommand="SELECT  [DepartmentId],[DepartmentCode] FROM PartCatDepartments where LocationId=@locationid ORDER BY [DepartmentCode] ">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="hflocationid" Name="locationid"  
                                PropertyName="Value" />
                        </SelectParameters>
                    </asp:SqlDataSource>

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 07 Jun 2018, 07:10 AM
Hi Galina,

I am afraid this requirement is not supported with Batch editing mode, which is different than other server-side modes:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-batch-edit-mode

For this scenario you can use the InPlace edit mode instead:
https://demos.telerik.com/aspnet-ajax/dropdowntree/examples/applicationscenarios/dropdowntreeingrid/defaultcs.aspx?product=grid%20https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/in-place


You can check the samples provided in the following post:
https://www.telerik.com/forums/radcombobox-cascading-inside-radgrid#GxsIQqyyPkqj1Za-mNbalg

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Galina
Top achievements
Rank 1
answered on 07 Jun 2018, 12:59 PM
Thank you
Tags
Grid
Asked by
Galina
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Galina
Top achievements
Rank 1
Share this question
or