enable all items - JavaScript

2 posts, 1 answers
  1. Aarsh
    Aarsh avatar
    192 posts
    Member since:
    Jun 2012

    Posted 07 Jun 2013 Link to this post

    Hello Friends,

    I've to dynamically & constatly (depending on what user selectes in another dropdown) keep disabling one item. This worked well ... but then if the user selects another item, the former one obiously stays disabled, so I tried to iterate thru all items and explicitly enable each one (if there is a better and efficient possible scenario, please psot with code example)



    Also please let me know how can I "unselect" the item ... as this combobox has checkboxes visible

    I tried following w/o suuceess

    item.select = false;
     
    and
     
    ddadditionalCaseTypes.Items[i].Selected = false;


    I am using folllowing code (hopefully this will also provide a good reference like I got referecne from : this post)

    Thanks,
    -Aarsh
               function jsfun_CategoryTypeChanged() {
     
                var CategoryTypesID, additionalCategoryTypesID, selectedValue, ddadditionalCategoryTypes;
                CategoryTypesID = "#ctl00_ContentPlaceHolder1_ddCategoryTypes";
                additionalCategoryTypesID = "#ctl00_ContentPlaceHolder1_ddAdditionalCategoryTypes";
                ddadditionalCategoryTypes = $find("ctl00_ContentPlaceHolder1_ddAdditionalCategoryTypes");
                debugger;
                var allItems = ddadditionalCategoryTypes.get_items();
                for (var i = 0; i < allItems.get_count(); i++) {
                    var thisItem = ddadditionalCategoryTypes.get_items().getItem(i);
                    if (thisItem != null)
                        thisItem.enable();
                }
                selectedValue = $(CategoryTypesID).val();
                if (ddadditionalCategoryTypes != null) {
                    var item = ddadditionalCategoryTypes.findItemByValue(selectedValue);
                    if (item != null) {
                        ddadditionalCategoryTypes.commitChanges();
                        item.disable();
                        ddadditionalCategoryTypes.trackChanges();
                    }
                }
     
            }

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Jun 2013 Link to this post

    Hi,

    I suppose you need to disable the item based on the first combobox selection and enable the former one if select another item. Please have a look into the following code.
    JS;
    function OnClientSelectedIndexChanged(sender, args)
    {
        var val = args.get_item().get_text(); // get the selected item of first Combobox
        var RadComboBox2 = $find("<%=RadComboBox2.ClientID%>");
        var getallItems = RadComboBox2.get_items();
        for (var i = 0; i < getallItems.get_count(); i++)
          {
              getallItems.getItem(i).set_enabled(true);
              getallItems.getItem(i).set_checked(true);
          }
       var item = RadComboBox2.findItemByText(val);
       item.set_checked(false);
       item.set_enabled(false);
     }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top