Using $find to find a control in a rad grid

3 posts, 1 answers
  1. Webguy
    Webguy avatar
    3 posts
    Member since:
    Apr 2008

    Posted 02 Feb 2010 Link to this post

    I currently have this radgrid and I'm trying to find the control rntbTotalTax2 in the footer using the $find client side command.   How can I find this control using client side scripting.

    Here is the javascript that I'm using to test with
    :

     

    <script type="text/javascript">

     

     

     

    function test(sender, args) {

     

     

    var parent1 = $find("rg2ConfirmCart");

     

     

    var child1 = $find("rntbTotalTax2", parent1);

     

     

     

    }

     

     

    </script>

     


    What happens is that child1 comes back null when test function is fired from a button that is not in the grid.  

    <

     

    telerik:RadGrid ID="rg2ConfirmCart" runat="server" AllowSorting="true" AutoGenerateColumns="false" OnItemDataBound="rg2CartConfirm_ItemDataBound" ShowFooter="true" >

     

    <

     

    MasterTableView CommandItemDisplay="None">

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn UniqueName="rg2GtcProduct" AllowFiltering="false">

     

     

    <HeaderTemplate>

     

     

    <asp:Label ID="rg2GtcProductHdr" runat="server" Text="Product"></asp:Label>

     

     

    </HeaderTemplate>

     

     

    <ItemTemplate>

     

     

    <asp:Label ID="lblProductName2" runat="server" Text="" Width="175"></asp:Label><br />

     

     

    <asp:Label ID="lblSku2" runat="server" Text="" Width="175"></asp:Label><br />

     

     

    </ItemTemplate>

     

     

    <FooterTemplate>

     

     

    <asp:Button ID="bEditCart" runat="server" Text="Edit Cart" PostBackUrl="~/ts1/index.aspx" /><br />

     

     

    <asp:Button ID="bReCalc" runat="server" Text="Recalculate" PostBackUrl="~/ts1/index.aspx" /><br />

     

     

    </FooterTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="rg2GtcQty" AllowFiltering="false" HeaderStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">

     

     

    <HeaderTemplate>

     

     

    <asp:Label ID="rg2GtcQtyHdr" runat="server" Text="QTY"></asp:Label>

     

     

    </HeaderTemplate>

     

     

    <ItemTemplate><asp:Label ID="lblQty2" runat="server" Text="" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="rg2GtcPrice" AllowFiltering="false" HeaderStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" FooterStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Right">

     

     

    <HeaderTemplate>

     

     

    <asp:Label ID="rg2GtcPriceHdr" runat="server" Text="Price"></asp:Label>

     

     

    </HeaderTemplate>

     

     

    <ItemTemplate><asp:Label ID="lblPrice2" runat="server" Text="" />

     

     

    </ItemTemplate>

     

     

    <FooterTemplate>

     

     

    <asp:Label ID="lblTotalExtPriceTxt2" runat="server" Text="Subtotal:" />

     

     

    </FooterTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="rg2GtcExtPrice" AllowFiltering="false" HeaderStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" FooterStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Right">

     

     

    <HeaderTemplate>

     

     

    <asp:Label ID="rg2GtcExtPriceHdr" runat="server" Text="Ext Price"></asp:Label>

     

     

    </HeaderTemplate>

     

     

    <ItemTemplate><asp:Label ID="lblExtPrice2" runat="server" Text="" />

     

     

    </ItemTemplate>

     

     

    <FooterTemplate>

     

     

    <asp:Label ID="lblTotalExtPrice2" runat="server" Text="0" CssClass="LabelStyleCartTax" />

     

     

    <telerik:RadNumericTextBox ID="rntbTotalTax2" Value="0" Label="Tax:" runat="server" CssClass="LabelStyleCartTax" Type="Percent" Width="35px" SelectionOnFocus="SelectAll" FocusedStyle-HorizontalAlign="Right" EnabledStyle-HorizontalAlign="Right" >

     

     

    </telerik:RadNumericTextBox>

     

     

    <telerik:RadNumericTextBox ID="rntbTotalShipping2" Value="0" Label="Shipping:" CssClass="LabelStyleCartTax" runat="server" Type="Currency" Width="65px" SelectionOnFocus="SelectAll" FocusedStyle-HorizontalAlign="Right" EnabledStyle-HorizontalAlign="Right" >

     

     

    </telerik:RadNumericTextBox>

     

     

    <telerik:RadNumericTextBox ID="rntbOrderTotal2" Value="0" ReadOnly="true" Label="Order Total:" CssClass="LabelStyleCartTax" runat="server" Type="Currency" Width="65px" SelectionOnFocus="SelectAll" FocusedStyle-HorizontalAlign="Right" EnabledStyle-HorizontalAlign="Right" >

     

     

    </telerik:RadNumericTextBox>

     

     

    </FooterTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    </Columns>

     

     

    <ExpandCollapseColumn Resizable="False" Visible="False">

     

     

    <HeaderStyle Width="20px" />

     

     

    </ExpandCollapseColumn>

     

     

    <RowIndicatorColumn Visible="False">

     

     

    <HeaderStyle Width="20px" />

     

     

    </RowIndicatorColumn>

     

     

     

    </MasterTableView>

     

     

    </telerik:RadGrid>

     

  2. Answer
    Steve
    Steve avatar
    1888 posts
    Member since:
    Dec 2008

    Posted 02 Feb 2010 Link to this post

    Does this work?

    var controlid = $telerik.$("[id$='rntbTotalTax2']").attr('id'); 
    var control = $find(controlid); 

  3. Webguy
    Webguy avatar
    3 posts
    Member since:
    Apr 2008

    Posted 03 Feb 2010 Link to this post

    That worked great!   Thank you!
Back to Top