Disable row in Telerik RadGrid with checkbox

4 posts, 0 answers
  1. Rafael
    Rafael avatar
    2 posts
    Member since:
    Apr 2013

    Posted 18 Apr 2013 Link to this post

    as I can disable a row with a checkbox inside a radgrid if I have the following code in aspx.

    <telerik:RadGrid ID="grdCaptDiaria" runat="server" AutoGenerateColumns="False"

    AllowPaging="True" PageSize="10">

    <HeaderStyle BorderStyle="Solid" BorderWidth="1px" Height="30px" HorizontalAlign="Center"

    BorderColor="#B0B0B0" BackColor="#EBEBEB" Font-Bold="True" Font-Italic="False"

    Font-Names="Arial,Helvetica,sans-serif" Font-Overline="False" Font-Size="10px"

    Font-Strikeout="False" Font-Underline="False" ForeColor="#666666" Wrap="True" />

    <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"

    Font-Underline="False" ForeColor="#999999" Wrap="True" />

    <PagerStyle Mode="NumericPages" PagerTextFormat="{4}Página {0} de {1}, registros del {2} al {3} de {5}" />

    <MasterTableView TableLayout="Fixed" NoMasterRecordsText="No existen Moliendas con los filtros proporcionados">

    <Columns>

    <telerik:GridBoundColumn HeaderText="Concepto" DataField="concepto" />

    <telerik:GridTemplateColumn HeaderText="Unidad" HeaderStyle-Width="25%">

    <ItemTemplate>

    <asp:Label ID="lblUnidad" runat="server" Text="Ton"></asp:Label>

    </ItemTemplate>

    </telerik:GridTemplateColumn>

    <telerik:GridTemplateColumn HeaderText="Valor" DataField="valor" HeaderStyle-Width="25%">

    <ItemTemplate>

    <asp:TextBox ID="txtValor" runat="server"></asp:TextBox>

    </ItemTemplate>

    </telerik:GridTemplateColumn>

    <telerik:GridTemplateColumn HeaderText="No Captura" HeaderStyle-Width="25%">

    <ItemTemplate>

    <asp:CheckBox ID="chkNoCaptura" Checked="false" OnChange="javascript:enableTextBox();" on runat="server" />

    </ItemTemplate>

    </telerik:GridTemplateColumn>

    </Columns>

     

    </MasterTableView>

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Apr 2013 Link to this post

    Hi,

    I guess you want to disable the TextBox in a row on on CheckBox check.

    C#:
    protected void grdCaptDiaria_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem ditem = (GridDataItem)e.Item;
            CheckBox chk = (CheckBox)ditem.FindControl("chkNoCaptura");
            int index = ditem.ItemIndex;
            chk.Attributes.Add("onchange", "handleChange('" + index + "')");
        }
    }

    Javascript:
    <script type="text/javascript">
        function handleChange(id) {
            var radGrid = $find('<%= grdCaptDiaria.ClientID %>');
            var MasterTable = radGrid.get_masterTableView();
            var row = MasterTable.get_dataItems()[id];
            row.findElement("txtValor").disabled = true;
        }
    </script>

    Thanks,
    Princy.
  3. Rafael
    Rafael avatar
    2 posts
    Member since:
    Apr 2013

    Posted 19 Apr 2013 Link to this post

    how enabled and disable the TextBox in a row on on CheckBox check if using a .



     function handleChange(id) {
                var radGrid = $find('<%= grdCaptDiaria.ClientID %>');
                var MasterTable = radGrid.get_masterTableView();
                var row = MasterTable.get_dataItems()[id];
                
                row.findElement("txtValor").disabled = true;
                
               
                  
               
            }
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Apr 2013 Link to this post

    Hi,

    i guess you want to enable and disable the TextBox. Please check the following code snippet.

    Javascript:
    <script type="text/javascript">
        function handleChange(id) {
            var radGrid = $find('<%= grdCaptDiaria.ClientID %>');
            var MasterTable = radGrid.get_masterTableView();
            var row = MasterTable.get_dataItems()[id];
     
            if (row.findElement("txtValor").disabled == false) {
                row.findElement("txtValor").disabled = true;
            }
            else {
                row.findElement("txtValor").disabled = false;
            }
        }
    </script>

    Thanks,
    Princy.
Back to Top