Checkall when disabled items

5 posts, 1 answers
  1. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 15 Oct 2014 Link to this post

    Disabled items of a ComboBox should be ignored when "Check all" is clicked or not.
    How can i achieve that? because the default behaviour does not take it in consideration.
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 20 Oct 2014 Link to this post

    Hello,

    Please use the following workaround in order to fix this behavior.

    //JavaScript
    var $T = $T = Telerik.Web.UI;
                $T.RadComboBox.prototype._onCheckAllItemsCheck = function (e) {
                    var target = $telerik.getTouchTarget(e),
                        items = this.get_items(),
                        args = {
                            checked: this._allChecked,
                            domEvent: e
                        };
     
                    if (target.nodeName == "LABEL") {
                        e.preventDefault();
                    }
     
                    //When the event is canceled the default behavior should be prevented,
                    //otherwise the checkbox will be checked when clicked.
                    if (this.raise_onCheckAllChecking(args)) {
                        e.preventDefault();
                        return;
                    }
     
                    this._checkedIndices = [];
                    this._allChecked = !this._allChecked;
     
                    for (var i = 0, length = items.get_count() ; i < length; i++) {
                         
                        if (this.get_items().getItem(i).get_enabled()) {
                            this.get_items().getItem(i)._setChecked(this._allChecked);
                        }         
                    }
     
                    this._updateCheckAllState();
                    this._updateCheckedIndices();
                    this._updateComboBoxText();
     
                    args.checked = this._allChecked;
                    this.raise_onCheckAllChecked(args);
     
                    if (this._postBackOnCheckAllCheck) {
                        var command = {
                            Command: "CheckAll",
                            CheckAllChecked: this._allChecked
                        };
                        this.postback(command);
                    }
                };
     
                $T.RadComboBox.prototype._updateCheckAllState = function () {
                     
                    // check/uncheck the Check All checkbox when item checked state is changed
                    var itemsCount = this.get_items().get_count(),
                        checkedItemsCount = this.get_checkedItems().length,
                        $checkAllCheckBox = $(this.get_checkAllCheckBox()),
                        enabledItemsCount = 0;
     
                    for (var i = 0; i < itemsCount; i++) {
                        if (this.get_items().getItem(i).get_enabled()) {
                            enabledItemsCount++;
                        }
                    }
     
                    if (enabledItemsCount > 0 && checkedItemsCount == enabledItemsCount) {
                        $checkAllCheckBox.prop("checked", true);
                        this._allChecked = true;
                    }
                    else {
                        $checkAllCheckBox.prop("checked", false);
                        this._allChecked = false;
                    }
                };



    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 20 Oct 2014 in reply to Boyan Dimitrov Link to this post

    Hi Boyan,
    this is not the most appropiate solution, it should be implemented by the RadComboBox class.

    As it seems that this behaviour is not implemented yet,
    i have tried to copy & paste your solution but i get the following JavaScript error: 'Telerik' is undefined.

  5. Answer
    Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 23 Oct 2014 Link to this post

    Hello,

    We are aware of this problem and here is the public item related to this bug. You can track its progress or vote for it.

    Please use the workaround in the attached file as a solution until this problem is fixed.

    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 23 Oct 2014 in reply to Boyan Dimitrov Link to this post

    Hi Boyan,

    I have just vote for it.
    Thanks for the temporary solution.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017