This is a migrated thread and some comments may be shown as answers.

enable all items - JavaScript

1 Answer 63 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Aarsh
Top achievements
Rank 1
Aarsh asked on 07 Jun 2013, 09:34 PM
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();
                }
            }
 
        }

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 10 Jun 2013, 09:38 AM
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.
Tags
ComboBox
Asked by
Aarsh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or