show textbox when user marks checkbox in radgrid

2 posts, 0 answers
  1. Hadoop
    Hadoop avatar
    8 posts
    Member since:
    Jun 2015

    Posted 23 Nov 2015 Link to this post

    I've a radgrid where there are checkboxex. The data comes from database. On of the value is "OTHERS". I want that when user checks the "OTHERS" checkbox, textbox should appear by its side. How can it be done using JAVASCRIPT or by using any radgrid property like OnPreRender ?

     

    <telerik:RadGrid ID="grid_diag_group" runat="server"                       
                            Width="100%"                     
                            AutoGenerateColumns="false"
                            HeaderStyle-HorizontalAlign="Left" >
                            <MasterTableView>
                                <Columns>
                                    <telerik:GridTemplateColumn UniqueName="TempCol1" HeaderText="Select" ReadOnly="true">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="CheckBox1" runat="server" />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:CheckBox ID="CheckBox2" runat="server" />
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn DataField="diag_code" Display="false" Visible="true" AutoPostBackOnFilter="false" ItemStyle-HorizontalAlign="Left" CurrentFilterFunction="Contains" />                              
                                    <telerik:GridBoundColumn DataField="diag_desc" UniqueName="diag_description" HeaderText="Diagnosis"
                                        AutoPostBackOnFilter="false" ItemStyle-HorizontalAlign="Left" />
                                </Columns>
                            </MasterTableView>
    </telerik:RadGrid>

     My UI looks like this >> ( checkbox == [])

    []  MALARIA
    []  T.B.
    []  GLYCOMA
    []  MEASELES
    []  FUNGAL INFECTION
    []  OTHERS
    When user checks the OTHERS checkbox, textbox should appear beside "OTHERS" inside the grid. How can I do it?  

    Please help !!! Thanks.

  2. Eyup
    Admin
    Eyup avatar
    3819 posts

    Posted 26 Nov 2015 Link to this post

    Hello Hadoop,

    You can achieve this requirement by replacing the diag_code column with a Template column:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/columns/column-types#gridtemplatecolumn

    Then, within the ItemTemplate next to the Label you will create a RadTextBox with its Visible property set to False. When the CheckBox1 is checked, you can then access the corresponding row, verify whether the text is OTHERS and if it is, you can set the Visible property of the textbox to true.

    I hope this will prove helpful.

    Regards,
    Eyup
    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
Back to Top