Retrieve RadGrid control dropdownlist selected values

5 posts, 0 answers
  1. nav100
    nav100 avatar
    48 posts
    Member since:
    Dec 2010

    Posted 24 Sep 2013 Link to this post

    I have RadGrid with DropDownlist. I am trying to find the value of each control by loop through using Javascript.  I am getting the findcontrol as 'null'. I have attached OnClientRatingSelectedIndexChanged in code behind for the dropdownlist 'Drop1'. What could be wrong? I appreciate any suggestions.

    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AlternatingItemStyle-HorizontalAlign="Left"
                                   OnNeedDataSource="RadGrid1_NeedDataSource">
                                    <MasterTableView DataKeyNames="level_id" PageSize="10">
                                        <Columns>
     <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Test"
                                                Visible="true">
                                                <ItemTemplate>
                                                    <asp:Panel ID="Panel1" runat="server">
                                                        <asp:DropDownList ID="Drop1" runat="server"                                                                                                                                        AutoPostBack="true">
                                                        </asp:DropDownList>
                                                    </asp:Panel>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                      </Columns>
    </MasterTableView>
    </telerik:RadGrid>

    Javascript

    function OnClientRatingSelectedIndexChanged(arg) {
    
            var grid = $find("<%=RadGrid1.ClientID %>");
            var MasterTable = grid.get_masterTableView();
            var Rows = MasterTable.get_dataItems();
            for (var i = 0; i < Rows.length; i++) {
                var row = Rows[i];
                var drop1 = row.findControl("Drop1");  
                var val1 = drop1.selectedValue;
            }   
  2. nav100
    nav100 avatar
    48 posts
    Member since:
    Dec 2010

    Posted 25 Sep 2013 Link to this post

    Telerik Experts, Could you please let me know how to retrieve the remaining Dropdownlist values when I select any one of Dropdownlist from RadGrid? I am stuck with this issue. Currently I have 5 rows in RadGrid. I have attached 
    OnClientRatingSelectedIndexChanged for this DropdownList. I would like to compare the other DropdownList 
    selected values when I select any one. Please let me know.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 26 Sep 2013 Link to this post

    Hello,

    Please try with the below code snippet.

    function test() {
     
                    var grid = $find("<%= RadGrid1.ClientID %>");
     
                    var MasterTable = grid.get_masterTableView();
                    var Rows = MasterTable.get_dataItems();
                    for (var i = 0; i < Rows.length; i++) {
                        var row = Rows[i];
                        var val1 = $(row.get_element()).find("div[id*='Panel1']").find("select[id*='Drop1']").val();
                        //OR
                        var val1 = $(row.get_element()).find("select[id*='Drop1']").val();;
                    }
     
                }

    Please check the below link for more information.

    Access RadGrid Row and Column on Client Side :- (Get Template Column Control)

    Please post your grid related question in below forum so you will get answer quickly.
    http://www.telerik.com/community/forums/aspnet-ajax/grid.aspx

    Thanks,
    Jayesh Goyani
  5. nav100
    nav100 avatar
    48 posts
    Member since:
    Dec 2010

    Posted 26 Sep 2013 Link to this post

    Jayesh,

    Thank you for the reply. I am getting       'Object doesn't support this property or method' error message on the following lines. Could you please suggest?

    $(row.get_element()).find("div[id*='pnlElmRating']").find("select[id*='element_rating']").val()

    $(row.get_element()).find("select[id*='element_rating']").val()


  6. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 27 Sep 2013 Link to this post

    Hi Nara,

    I have prepared a sample RadGrid web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

    Regards,
    Eyup
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017