locked
Repeater textbox, button not disabling RRS feed

  • Question

  • User1126057398 posted

    I had added a class to disable Telerik autocomplete, textbox, button inside repeater. Though, the background color of disabled td changes to grey but controls like button,etc. are not disabled. What I am trying to do is initially only anchor tag column is enabled inside repeater. But when one clicks on anchor tag, other columns are enabled. How can this be achieved?

    .disablecol{ background-color: #ddd; cursor: not-allowed;}

    $(".aweekdy").click(function () {
    $(this).parent().next('td').removeClass('disablecol');
    $(this).parent().next('td').next('td').removeClass('disablecol');
    $(this).parent().next('td').next('td').next('td').removeClass('disablecol');
    });

    <asp:Repeater ID="repWeekDayActivity" runat="server">
    <HeaderTemplate>
    <table class="table table-hover" border="1">
    <tr>
    <th scope="col">Week Days</th>
    <th scope="col">Activity Name</th>
    <th scope="col">Duration(Min)</th>
    <th scope="col">&nbsp;</th>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td>
    <a class="aweekdy" id="ancWeekday"><%#Eval("WeekDay") %></a>
    <asp:HiddenField ID="hfWeekDayId" Value='<%#Eval("WeekDayId") %>' runat="server" />
    </td>
    <td class="disablecol">
    <telerik:RadAutoCompleteBox runat="server" ID="txtWeekdayActivity" CssClass="weekdayact" DropDownHeight="100" Width="250" TextSettings-SelectionMode="Single" EmptyMessage="Enter Activity Name to Search..." OnClientLoad="OnClientLoad" Skin="Bootstrap">
    <WebServiceSettings Path="~/Service_Telerik.asmx" Method="GetPAActivitySearchListExtnAutoTelerik" />
    </telerik:RadAutoCompleteBox>
    </td>
    <td class="disablecol">
    <asp:TextBox ID="txtDuration" runat="server" onkeypress="return validateDecimal(event)" class="form-control cduration"></asp:TextBox></td>
    <td class="disablecol">
    <asp:Button ID="btnweekActivityAdd" Text="Add" runat="server" CssClass="btn btn-primary btnweekadd" OnClick="AddSpecificWeekDayDtl" />
    </td>
    </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
    </asp:Repeater>

    Thursday, July 4, 2019 5:59 AM

Answers

  • User1126057398 posted

    Thanks. Inside repeater I had set Enabled=false for controls like Textbox, button and in jquery done it like below:

    $(".aweekdy").click(function () {
    var row = $(this).closest('tr');
    row.find('td').removeClass('disablecol');

    //Enable Textbox,button inside clicked Repeater row
    row.find("input").prop("disabled", false);
    // row.find("input[id$=btnweekActivityAdd]").prop("disabled", false);
    });

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 8, 2019 10:56 AM

All replies

  • User665608656 posted

    Hi geetasks,

    According to your description,I suggest you could first add 'disablecol' class name to the other line's td when you click one line, then remove current line's td's class name which you have clicked.

    You could use slice() method to get rid of some parts, you could refer to this link: https://api.jquery.com/slice/

    For more details ,you could refer to the following code:

        <script type="text/javascript">
            $(function () { 
                $(".aweekdy").click(function () {
    //below part is to add classname to the other lines except title line and click line. $(this).parents('tr').siblings().slice(1).each(function () { $(this).children().slice(1).each(function () { $(this).addClass('disablecol'); }); });
    //below part is to remove classname to the current click line. $(this).parents('tr').children().slice(1).each(function () { $(this).removeClass('disablecol'); }); }); }) </script>

    Here is the result of this work demo:

    Best Regards,

    YongQing.

    Thursday, July 4, 2019 7:52 AM
  • User1126057398 posted

    Thanks Yongqing. But disablecol class which I had mentioned, fails to disable textbox, etc. inside Repeater. I want to disable all controls inside Repeater. But after anchor tag is clicked want to enable them.

    Sunday, July 7, 2019 4:56 PM
  • User665608656 posted

    Hi geetasks,

    According to your description, I want to confirm with you whether you want to really disable these controls or just disable them in style through disablecol?

    If you want to really disable it, you can add the attribute Enabled="false" to the corresponding control, and then use $("#ID").attr("disabled", false) when it is enabled in jquery.

    I want to disable all controls inside Repeater. But after anchor tag is clicked want to enable them.

    Based on this requirement, I have revised the code for your reference:

        <script type="text/javascript">
            $(function () {
                $(".aweekdy").click(function () {
                    $(this).parents('tr').siblings().slice(1).each(function () {
                        $(this).children().slice(1).each(function () {
                            $(this).removeClass('disablecol');
    // If you have really disabled controls,You can use the following forbidden statements to enable controls. //$(this).children().eq(0).attr("disabled", false); }); }); $(this).parents('tr').children().slice(1).each(function () { $(this).removeClass('disablecol');
    // If you have really disabled controls,You can use the following forbidden statements to enable controls. // $(this).children().eq(0).attr("disabled", false); }); }); }) </script>

    The result of this work demo:

    Best Regards,

    YongQing.

    Monday, July 8, 2019 1:21 AM
  • User1126057398 posted

    Thanks. Inside repeater I had set Enabled=false for controls like Textbox, button and in jquery done it like below:

    $(".aweekdy").click(function () {
    var row = $(this).closest('tr');
    row.find('td').removeClass('disablecol');

    //Enable Textbox,button inside clicked Repeater row
    row.find("input").prop("disabled", false);
    // row.find("input[id$=btnweekActivityAdd]").prop("disabled", false);
    });

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 8, 2019 10:56 AM