Results 1 to 4 of 4

Thread: How to disable an item in Dropdwn box?

  1. #1
    Sencha User
    Join Date
    Nov 2016
    Posts
    5
    Vote Rating
    0
      0  

    Default How to disable an item in Dropdwn box?

    Hi,

    I am a newbie to EXT JS 4.x and I am trying to disable an item in a Dropdown/Combo box
    The option in the DD box must be visible and disabled so that the user can not click to select it.

    Here is my function:

    // The following function accepts the display value of an item and if found
    // in the Dropdown box, disables or enables the item as per the Boolean disable

    // Example: updateAFDLTaskOption('AFDL_FILES_TO_VENDOR', true);
    function updateAFDLTaskOption(eventType, disable)
    {
    var task_type_combo_box;
    var retVal = "Failed"; // default return value

    // Get the Widget Control
    task_type_combo_box = Ext.ComponentQuery.query('xcp_dropdown_list[xcpId="task_type_list"]')[0];

    // Examine the contents
    task_type_combo_box.getStore().each(function (r)
    {

    if(disable)
    {
    if(r.data.v_out_event_type == eventType) // Matches Item value
    {
    r.data.disabled = true; // Disable the Item
    retVal = "Disabled";
    }
    }
    else
    {
    if(r.data.v_out_event_type == eventType)
    {
    r.data.disabled = false; // Enable the Item
    retVal = "Enabled";
    }
    }
    });
    // Refresh the DD box to show the updated items
    task_type_combo_box.doComponentLayout();

    return retVal;
    }

    I tested the function in console, there are no errors and all the items show as enabled
    Looks like the refresh of DD is not working.
    Please suggest the correct function to refresh the DD Control

    Thanks
    Raj

  2. #2
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,483
    Answers
    484
    Vote Rating
    279
      0  

    Default

    Here's a thread that might help:
    https://www.sencha.com/forum/showthread.php?261806

    Lifecycle management for your web apps

  3. #3
    Sencha User
    Join Date
    Nov 2016
    Posts
    5
    Vote Rating
    0
      0  

    Default Disabling an Item in a Dropdown box

    Quote Originally Posted by Gary Schlosberg View Post
    Thanks Gary!!

    I wanted to disable an item in a Dropdown box so that the user can not select it.
    For this, I was planning to get the Component of the Dropdown box
    and add a listener, say, the 'beforeselect' listener and return false for the desired item

    Here is the code

    ecmDisableTaskOption = function ()
    { var task_type_combo_box;

    // Get the Existing ComboBox Component
    task_type_combo_box = Ext.ComponentQuery.query('xcp_dropdown_list[xcpId="task_type_list"]')[0];
    // Add a listener for this Combo
    task_type_combo_box.on('change', function(combo, record, index) {

    console.log('new', record, 'old', index);
    });
    return "Done.......";
    };


    // Call the function to setup the desired listener
    ecmDisableTaskOption();


    Now, if I select an Item in the Dropdown list with the Id 'task_type_list' on the page
    I would expect to see some log on the console, but, nothing happens

    Appreciate your help!!

    Thanks
    Raj

  4. #4
    Sencha User
    Join Date
    Nov 2016
    Posts
    5
    Vote Rating
    0
      0  

    Default

    Hi,
    I wanted to disable an item in a Dropdown box so that the user can not select it.
    For this, I was able to get the Component of the Dropdown box
    and add the 'beforeselect' listener and return false for the desired item
    Here is the code
    ecmDisableAFDLTaskOption(eOption)
    {
    var task_type_combo_box;
    // Get the ComboBox Component
    task_type_combo_box = Ext.ComponentQuery.query('xcp_dropdown_list[xcpId="task_type_list"]')[0];
    task_type_combo_box.on('beforeselect',function(combo, record, index, eOpts)
    {
    if(record.data.v_out_event_type == eOption) {
    // Cancel the default action
    return false;
    }
    else {
    // Allow the default action
    return true;
    }
    });
    }
    // Call the function to setup the desired listener
    ecmDisableAFDLTaskOption('AFDL_FILES_TO_VENDOR');

    Now, I am Unable to select the desired Item in the Dropdown list -- Means the function is working!!!
    However, I want to see the Item in the Disabled Style so that it appears as Disabled
    Please suggest how to add the disabled style to the Item
    Appreciate your help!!
    Thanks
    Raj

Similar Threads

  1. Replies: 1
    Last Post: 25 Jan 2016, 11:55 PM
  2. How to disable ComboBox item?
    By spectdev in forum Ext GWT: Q&A
    Replies: 2
    Last Post: 6 Dec 2012, 3:46 PM
  3. Replies: 1
    Last Post: 25 Sep 2012, 11:04 PM
  4. x-item-disable in ie and ff
    By netbox in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 13 Apr 2009, 9:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •