clientside find control inside radgrid

3 posts, 1 answers
  1. Emre
    Emre avatar
    1 posts
    Member since:
    May 2012

    Posted 05 Jul 2012 Link to this post

      I want to find 2 radtextbox in clientside that is inside a radgrid ,and radgrid is inside a radlistview.But all examples on internet are for one root radgrid,so I need an example in which I can find the textboxes on clientside and use them for calculations.If the radtextboxes are in root page,i can use this easily,
    function OnClientValueChanged(sender, args) {
     
                   var tx_adet = $find("<%= RadTextBoxAdet.ClientID %>");
                   var tx_birim = $find("<%= RadNumericTextBoxBirimFiyat.ClientID %>");
                   var labeltoplam = $find("<%= RadNumericTextBoxToplam.ClientID %>");
                   labeltoplam.set_value(tx_adet.get_value() * tx_birim.get_value());
                 
               }

    But in my scenario,these textboxes are inside 2 data components,root listview and inside listview a radgrid.

    <telerik:RadListView ID="RadListView1" runat="server"
                                  DataSourceID="SqlDataSourceAlimKalemiKategori0"
                                  onitemdatabound="RadListView1_ItemDataBound">
                                  <LayoutTemplate>
                                      <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                                  </LayoutTemplate>
                                  <ItemTemplate>
                                       <asp:HiddenField ID="HiddenFieldid" runat="server" Value='<%# Eval("id") %>'/>
                      <h2>    <%# Eval("ad") %></h2>
               <telerik:RadGrid ID="RadGrid_alimedetaylar" runat="server"
                                           CellSpacing="0"  ShowFooter="true" AllowAutomaticUpdates="false" AllowAutomaticInserts="false"
                         DataSourceID="SqlDataSourceAlimKalemiGrid" GridLines="None" Culture="tr-TR"
                         OnItemCommand="RadGrid_alimedetaylar_ItemCommand"
                                   onitemdatabound="RadGrid_alimedetaylar_ItemDataBound">
                         <MasterTableView DataSourceID="SqlDataSourceAlimKalemiGrid" AutoGenerateColumns="False" DataKeyNames="id" AllowAutomaticUpdates="false" AllowAutomaticInserts="false">
           <EditFormSettings EditFormType="Template">
                   <EditColumn FilterControlAltText="Filter EditCommandColumn column" UniqueName="EditCommandColumn1">
                   </EditColumn>
                   <FormTemplate>
                      <telerik:RadScriptBlock ID="alimekalemirad" runat="server">
        
              <script type="text/javascript">
                  function OnClientValueChanged(sender, args) {
                     //in here I want to find RadTextBoxAdet and RadNumericTextBoxBirimFiyat 

                  
                      
                  }
         </script>
         </telerik:RadScriptBlock>
                             <telerik:RadTextBox ID="RadTextBoxAdet" runat="server" EmptyMessage="Adet"
                                     InputType="Number" LabelCssClass="" LabelWidth="64px" Width="80px">
                                    <ClientEvents OnValueChanged="OnClientValueChanged" />
                                 </telerik:RadTextBox>
                             </td>
                             <td>
                                 <telerik:RadNumericTextBox ID="RadNumericTextBoxBirimFiyat" runat="server"
                                     Culture="tr-TR" LabelCssClass="" LabelWidth="40px"
                                     Type="Currency" Width="100px" EmptyMessage="Birim Fiyat">
                                     <NumberFormat ZeroPattern="n TL" />
                                         <ClientEvents OnValueChanged="OnClientValueChanged" />
                                 </telerik:RadNumericTextBox>
                             </td>
                             <td>
                                 <telerik:RadNumericTextBox ID="RadNumericTextBoxToplam" runat="server"
                                     Culture="tr-TR" LabelCssClass="" LabelWidth="64px" Type="Currency"
                                     Width="100px" ReadOnly="True" Skin="Windows7">
                                     <NumberFormat ZeroPattern="n TL" />
                                 </telerik:RadNumericTextBox>
                   </FormTemplate>
               </EditFormSettings>
                            
                           
                             <Columns>
                               
                               
                                 <telerik:GridBoundColumn DataField="toplam_fiyat" DataType="System.Decimal"
                                     FilterControlAltText="Filter toplam_fiyat column" HeaderText="Toplam Fiyat" FooterAggregateFormatString="{0:c}" Aggregate="Sum"  FooterText="Total: "
                                     SortExpression="toplam_fiyat" UniqueName="toplam_fiyat">
                                 </telerik:GridBoundColumn>
                                   
                         <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column"
                                   HeaderText="Projelerini Göster" UniqueName="TemplateColumn">
                                   <ItemTemplate>
                                       <a class="gridinserthref" href="#" onclick="return showradwindow('alim_kalemi_degistir');"
                               style="color: Red;">Yeni Kayıt Ekle +</a>
                                       </ItemTemplate>
                               </telerik:GridTemplateColumn>
                             </Columns>
                    
                                 
                         </MasterTableView>
                          
                         <FilterMenu EnableImageSprites="False">
                         </FilterMenu>
                     </telerik:RadGrid>
                          
                                  </ItemTemplate>
                              </telerik:RadListView>
    Any help is appreciated,thanks.
  2. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 05 Jul 2012 Link to this post

    Hello,


    function OnClientValueChanged(sender, args) {
                   // Do not forget to add jquery in reference
                   var SenderId = sender.get_element().id; // sender.get_id();
                   var RadTextBoxAdet = $("#" + SenderId).get(0);
                   var RadNumericTextBoxBirimFiyat = $("#" + SenderId.replace("RadTextBoxAdet", "RadNumericTextBoxBirimFiyat")).get(0);
     
               }

    OR

    How to access the control from itemtemplate in Radgrid on client side

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. amy
    amy avatar
    1 posts
    Member since:
    Sep 2016

    Posted 19 Sep in reply to Jayesh Goyani Link to this post

    Hi,

    I tried this code to find the value of the raddatepicker(selected date) and it worked fine. But I have a problem while I'm trying to display the selected date in another raddatepicker control. Could you please help me.

    Thanks in advance.

     

Back to Top