RadGrid RadDropDownList Ajax Issue

2 posts, 0 answers
  1. Mohammed
    Mohammed avatar
    2 posts
    Member since:
    Aug 2015

    Posted 24 Aug 2015 Link to this post


    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" />
                   <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 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>
                           <telerik:RadDropDownList AutoPostBack="true" Width="55px" runat="server"  DataTextField="OptionValue" ID="txtSL" DataSourceID="SqlDataSource3" 
                   <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>
                           <telerik:RadDropDownList Width="55px" runat="server"  DataTextField="OptionValue" ID="txtReading" DataSourceID="SqlDataSource3"  DataValueField="OptionValue">
                   <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>
                           <telerik:RadDropDownList Width="55px" runat="server"  DataTextField="OptionValue" ID="txtWriting" DataSourceID="SqlDataSource3"  DataValueField="OptionValue">
                   <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>
                           <telerik:RadDropDownList Enabled="false" Width="55px" runat="server"  DataTextField="OptionValue" ID="txtOverallPass" DataSourceID="SqlDataSource3"  DataValueField="OptionValue">
                <CommandItemSettings RefreshImageUrl="../assets/img/refresh32.png"  />
            <ClientSettings AllowKeyboardNavigation="true" >
                <ClientEvents OnBatchEditCellValueChanged="BatchEditCellValueChanged" OnCommand="OnGridCommand"   />
               <Resizing AllowColumnResize="True" />


  2. Kostadin
    Kostadin avatar
    1733 posts

    Posted 27 Aug 2015 Link to this post

    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.

    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
Back to Top