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

RadGrid RadDropDownList Ajax Issue

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 1
Mohammed asked on 24 Aug 2015, 09:08 AM

Hi,

I have a RadGrid which is set to always run in batch edit mode. I have four RadDropDownList controls in the grid and would like the fourth RadDropDownList to be set to True if the first three are all set to True. I would prefer to do this using AJAX or something since I don't want the page to load each time one of the RadDropDownList values is changed.

If I set AutoPostBack = true on the RadDropDownList, once I click off the row the selected value in the RadDropDownList disappears and is just set as a blank value.

The 'OverallPass' is the one that needs to be updated.

I have only set AutoPostBack = True for the first RadDropDownList in this example.

<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowFilteringByColumn="True" MasterTableView-EditMode="Batch"
       OnBatchEditCommand="RadGrid1_BatchEditCommand" AllowPaging="true" PageSize="20"  >
       <GroupingSettings CaseSensitive="false" />
       <mastertableview datakeynames="RulCode" datasourceid="SqlDataSource1" AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom"  CommandItemSettings-ShowAddNewRecordButton="false"
           EditMode="Batch" AllowNaturalSort="true" >
           <BatchEditingSettings EditType="Row" OpenEditingEvent="Click" />
           <Columns>
               <telerik:GridTemplateColumn FilterControlWidth="60%" ReadOnly="true" DataField="PerCode" FilterControlAltText="Filter PerCode column" HeaderText="PerCode" UniqueName="PerCode" SortExpression="PerCode" DataType="System.String">
                   <HeaderStyle Width="70px" HorizontalAlign="Left" />
                   <ItemTemplate><%# Eval("PerCode") %> </ItemTemplate>
               </telerik:GridTemplateColumn>
               <telerik:GridTemplateColumn FilterControlWidth="60%" ReadOnly="false" DataField="SL" FilterControlAltText="Filter SL column" HeaderText="S+L" UniqueName="SL" SortExpression="Team" DataType="System.String">
                   <HeaderStyle Width="70px" HorizontalAlign="Left" />
                   <ItemTemplate><%# Eval("SL") %></ItemTemplate>
                   <EditItemTemplate>
                       <telerik:RadDropDownList AutoPostBack="true" Width="55px" runat="server"  DataTextField="OptionValue" ID="txtSL" DataSourceID="SqlDataSource3" 
                       DataValueField="OptionValue">
                       </telerik:RadDropDownList>
                   </EditItemTemplate>
               </telerik:GridTemplateColumn>
               <telerik:GridTemplateColumn FilterControlWidth="60%" ReadOnly="false" DataField="Reading" FilterControlAltText="Filter Reading column" HeaderText="Reading" UniqueName="Reading" SortExpression="Reading" DataType="System.String">
                   <HeaderStyle Width="70px" HorizontalAlign="Left" />
                   <ItemTemplate><%# Eval("Reading") %></ItemTemplate>
                   <EditItemTemplate>
                       <telerik:RadDropDownList Width="55px" runat="server"  DataTextField="OptionValue" ID="txtReading" DataSourceID="SqlDataSource3"  DataValueField="OptionValue">
                       </telerik:RadDropDownList>
                   </EditItemTemplate>
               </telerik:GridTemplateColumn>
               <telerik:GridTemplateColumn FilterControlWidth="60%" ReadOnly="false" DataField="Writing" FilterControlAltText="Filter Writing column" HeaderText="Writing" UniqueName="Writing" SortExpression="Writing" DataType="System.String">
                   <HeaderStyle Width="70px" HorizontalAlign="Left" />
                   <ItemTemplate ><%# Eval("Writing") %></ItemTemplate>
                   <EditItemTemplate>
                       <telerik:RadDropDownList Width="55px" runat="server"  DataTextField="OptionValue" ID="txtWriting" DataSourceID="SqlDataSource3"  DataValueField="OptionValue">
                       </telerik:RadDropDownList>
                   </EditItemTemplate>
               </telerik:GridTemplateColumn>
               <telerik:GridTemplateColumn FilterControlWidth="60%" ReadOnly="false" DataField="OverallPass" FilterControlAltText="Filter OverallPass column" HeaderText="Overall Pass" UniqueName="OverallPass" SortExpression="OverallPass" DataType="System.String">
                   <HeaderStyle Width="70px" HorizontalAlign="Left" />
                   <ItemTemplate><%# Eval("OverallPass") %></ItemTemplate>
                   <EditItemTemplate>
                       <telerik:RadDropDownList Enabled="false" Width="55px" runat="server"  DataTextField="OptionValue" ID="txtOverallPass" DataSourceID="SqlDataSource3"  DataValueField="OptionValue">
                       </telerik:RadDropDownList>
                   </EditItemTemplate>
               </telerik:GridTemplateColumn>
           </Columns>
            <CommandItemSettings RefreshImageUrl="../assets/img/refresh32.png"  />
       </mastertableview>
        <ClientSettings AllowKeyboardNavigation="true" >
            <ClientEvents OnBatchEditCellValueChanged="BatchEditCellValueChanged" OnCommand="OnGridCommand"   />
           <Resizing AllowColumnResize="True" />
       </ClientSettings>
   </telerik:RadGrid>

 

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 27 Aug 2015, 07:54 AM
Hi Mohammed,

Note batch editing enables inline client-side editing and performing multiple changes before the user decides to either apply the changes or cancel them. That means during the edit no postback is perform. In case you need to automatically popualte a control you have to ahcieve that completely on the client, otherwise if you perform a postback all changes will be lost.
Generally you need to disable the AutoPostBack property and hook OnClientSelectedIndexChange event. When the event is fired you have to access all DropDown controls and check their values. This way you can see whether the last DropDown control should be set to true or false. Note that you will be able to get the dropdown controls only if you are using a row edit type. Otherwise you have to get the cell value instead of the dropdown one.
I would recommend you to examine the following help article for more information regarding this edit mode type. Also you can check out the grid Client API.

Regards,
Kostadin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or