Disabled child checkboxes

4 posts, 0 answers
  1. Aniket
    Aniket avatar
    12 posts
    Member since:
    Dec 2015

    Posted 22 Dec 2015 Link to this post

    Hi,

     I was wondering if there is a way to disable child check boxes when parent check boxes have been disabled. I have used the selectableMode property to disable parent checkbox but am running into issue disabling child checkbox using same property.

     C#:

    //This is for disabling child checkbox
     
    protected void BindChildGrid(GridDataItem parentItem)
     
            {
                var ucQuoteRows = parentItem.ChildItem.FindControl("ucExpiringRealServices") as UserControls.CustomerGrid;
                CheckBox checkBox = (CheckBox)parentItem["BulkActionSelect"].Controls[0];
                 
                if (ucQuoteRows != null)
                {
                    checkBox.Attributes.Add("data-customergridid", ucQuoteRows.ClientID);
                    //var envelopeName = parentItem.GetDataKeyValue("Name");
                    ucQuoteRows.ParentId = parentItem.GetDataKeyValue("ObjectId").ToString();
                    /*ucQuoteRows.ExportFileNamePrefix = envelopeName.ToString();
                    ucQuoteRows.TaInfoEnable = RoleEngine.CurrentUserHasTARead();*/
                    //BindCustomerGrid(ucQuoteRows, null);
                    if (parentItem.SelectableMode == GridItemSelectableMode.None)
                    {
                        ucQuoteRows.AllowSelection = false;
                    }
                    else if (parentItem.SelectableMode == GridItemSelectableMode.ServerAndClientSide)
                    {
                        ucQuoteRows.AllowSelection = true;
                    }
                    ucQuoteRows.ColumnCollection = null;
                    ucQuoteRows.Rebind();
                }
            }
     
      
     
    //this correctly disables parent checkbox
    protected void rgExpiringServices_ItemDataBound(object sender, GridItemEventArgs e)
            {
                if (e.Item is GridDataItem)
                {
                     
                    var dataItem = ((GridDataItem)e.Item);
                    var ObjectId = Guid.Parse(dataItem.GetDataKeyValue("ObjectId").ToString());
     
                    e.Item.SelectableMode = this.DisabledIds.Contains(ObjectId) ? GridItemSelectableMode.None : GridItemSelectableMode.ServerAndClientSide;
     
                }
            }

    aspx:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ExpiringServices.aspx.cs" Inherits="FNA.NRTT.Website.Customer.Service.ExpiringServices" %>
    <%@ Register TagPrefix="nrtt" TagName="CustomerGrid" Src="~/UserControls/CustomerGrid.ascx" %>
    <%@ Register TagPrefix="nrtt" TagName="DisplayClientDefinedField" Src="~/UserControls/DisplayClientDefinedField.ascx" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
    </asp:Content>
    <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
        <h2><asp:Literal ID="ltPageTitle" runat="server" Text="<%$ Resources:NrttLanguage, Services %>"></asp:Literal></h2>
     
        <asp:DropDownList ID="ddlInterval" runat="server" style="text-align:right" OnSelectedIndexChanged="ddlInterval_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem Text="30 days" Value="0" />
            <asp:ListItem Text="90 days" Value="1" />
            <asp:ListItem Text="Forever" Value="2" />
        </asp:DropDownList>
        <br />
        <nrtt:DisplayClientDefinedField runat="server" ID="ucDisplayCDFS" OnNeedCdfDefinitions="ucDisplayCDFS_NeedCdfDataDefinition" OnFilterChanged="ucDisplayCDFS_FilterCDFS"/>
        <telerik:RadGrid ID="rgExpiringServices" OnNeedDataSource="rgExpiringServices_NeedDataSource" OnItemCommand="rgExpiringServices_ItemCommand" AllowFilteringByColumn="true" OnPreRender="rgExpiringServices_PreRender" runat="server" Skin="Black" AllowMultiRowSelection="true" OnItemDataBound="rgExpiringServices_ItemDataBound" AllowPaging="true">
            <ClientSettings Selecting-AllowRowSelect="true" Selecting-UseClientSelectColumnOnly="true" ClientEvents-OnRowSelected="nestedGridRowSelected" ClientEvents-OnRowDeselected="nestedGridRowDeselected"></ClientSettings>
            <MasterTableView DataKeyNames="ObjectId, Name" AutoGenerateColumns="false" ShowFooter="true" HierarchyLoadMode="ServerOnDemand" EnableHierarchyExpandAll="true" AllowFilteringByColumn="true">
                <Columns>
                    <telerik:GridClientSelectColumn UniqueName="BulkActionSelect" HeaderText="<%$ Resources:NrttLanguage, BulkAction %>" ></telerik:GridClientSelectColumn>
                    <telerik:GridButtonColumn ButtonType="ImageButton" ButtonCssClass="btnTiny btnApprove" UniqueName="Renew" CommandName="Renew" ImageUrl="~/Images/blank16.png" HeaderStyle-Width="16px" ItemStyle-Width="16px" ></telerik:GridButtonColumn>
                    <telerik:GridButtonColumn ButtonType="ImageButton" ButtonCssClass="btnTiny btnDelete" UniqueName="Terminate" CommandName="Terminate" ImageUrl="~/Images/blank16.png" HeaderStyle-Width="16px" ItemStyle-Width="16px" ></telerik:GridButtonColumn>
                    <telerik:GridNumericColumn UniqueName="Name" DataField="Name" HeaderText="<%$ Resources:NrttLanguage, CustomerReference %>" DataType="System.String"> </telerik:GridNumericColumn>
                    <telerik:GridDateTimeColumn DataField="DateExpiration" DataType="System.DateTime" FilterControlAltText="Filter DateImportant column" HeaderText="<%$ Resources:NrttLanguage, DateExpiring%>" SortExpression="DateImportant" UniqueName="DateImportant" DataFormatString="{0:d}" >
                    </telerik:GridDateTimeColumn>
                    <telerik:GridNumericColumn UniqueName="Daysuntilexpired" DataField="DaysUntilExpiration" HeaderText="<%$ Resources:NrttLanguage, daysuntilexpired %>" > </telerik:GridNumericColumn>
                    <telerik:GridBoundColumn UniqueName="Services" DataField="ServiceInReferenceString" HeaderText="<%$ Resources:NrttLanguage, Services %>" ></telerik:GridBoundColumn>
                    <telerik:GridNumericColumn UniqueName="Parcelcount" DataField="RealInReference" HeaderText="<%$ Resources:NrttLanguage, ParcelCount %>" > </telerik:GridNumericColumn>
                </Columns>
                <NestedViewTemplate>
                    <nrtt:CustomerGrid ID="ucExpiringRealServices" runat="server" AllowSelection="true" OnNeedDataSource="ucExpiringRealServices_NeedDataSource" OnNeedColumnCollection="ucExpiringRealServices_NeedColumnCollection" OnItemDataBound="ucExpiringRealServices_ItemDataBound" ></nrtt:CustomerGrid>
                </NestedViewTemplate>
            </MasterTableView>
        </telerik:RadGrid>
        <div style="text-align:right">
            <asp:RadioButton ID="Extend" Text="Extend" Checked="true" GroupName="whattodo" runat="server" />
            <asp:RadioButton ID="Terminate" Text="Terminate" Checked="false" GroupName="whattodo" runat="server" />
            <telerik:RadButton ID="rbtnSubmitSelection" runat="server" Text="<%$ Resources:NrttLanguage, RequestPayment %>" Skin="Black" SingleClick="true" OnClick="rbtnSubmitSelection_Click"></telerik:RadButton>
        </div>
    </asp:Content>

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 24 Dec 2015 Link to this post

    Hi,

    WIthin the OnItemDataBound event of your nested grid you could get reference to the parent data item and set its SelectableMode to the nested items:
    protected void ucExpiringRealServices_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            (e.Item as GridDataItem).SelectableMode = (e.Item.OwnerTableView.OwnerGrid.NamingContainer as GridNestedViewItem).ParentItem.SelectableMode;
        }
    }

    Hope this helps.


    Regards,
    Konstantin Dikov
    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Aniket
    Aniket avatar
    12 posts
    Member since:
    Dec 2015

    Posted 29 Dec 2015 in reply to Konstantin Dikov Link to this post

    This won't work since it is a custom create user control. 
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 29 Dec 2015 Link to this post

    Hello,

    For custom user control you could try to get reference to the checkboxes in the NestedViewTemplate with FindControl method and manually disable them.


    Regards,
    Konstantin Dikov
    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
UI for ASP.NET MVC is VS 2017 Ready