This project is read-only.

Item disabled property

Oct 31, 2011 at 12:53 PM

hi,

i have a need to support an additional item property - "disabled" - are there any plans to support something like this?

for now, i've added myself minimal support - i.e. specify whether an item is disabled (false by default) when creating the menu. More complete support will also allow to dynamically (programmatically) turn it on/off.

I limited the change to the $.fn.dynamicContextMenu.createMenuItem() method (@version 2.0.0) - my changes are marked with "Start YG" ... "End YG"

createMenuItem: function (item) {
    var tempItem = document.createElement("li");
    tempItem.id = item.value;

    if (item.iconUrl != undefined && item.iconUrl != null) {
        var imgIcon = new Image();
        imgIcon.src = item.iconUrl;
        imgIcon.alt = item.text;
        imgIcon.className = this.get_style().itemIconCssClass;

        tempItem.appendChild(imgIcon);
    }

// Start YG
    //$(tempItem).click({ sender: this }, this.contextMenu_Click);
// End YG               

    tempItem.appendChild(document.createTextNode(item.text));

// Start YG
    if (item.disabled) {
        $(tempItem).addClass(this.get_style().itemDisabledCssClass || '');
    }
// End YG               
    else if (item.children != undefined && item.children != null && item.children.length > 0) {
        tempItem.className += " " + this.get_style().subLevelHolderItemCssClass;

        this.get_paramsCopy().id = tempItem.id + "_children";
        this.get_paramsCopy().items = item.children;
        this.get_paramsCopy().parentMenu = this;
        this.get_paramsCopy().onItemClick = item.onChildItemClick;

        $(tempItem).dynamicContextMenu(
            this.get_paramsCopy()
        );
    }
// Start YG
    else {
        $(tempItem).click({ sender: this }, this.contextMenu_Click);
    }
// End YG               

    return tempItem;
},

Added the following fields to the defintion of the control:

- new item property - "disabled" (boolean) default=false

- new style property: "itemDisabledCssClass", e.g.

   ol.DynamicContextMenuContainer li.disabled-item,
   ol.DynamicContextMenuContainer li:hover.disabled-item
   {
       color            : #AFAFAF;   
       cursor            : default;
       background-color: transparent;
   }       

Jun 27, 2012 at 3:16 PM

Hi, yarongilboa!

Sadly, I had no email notification and I've never known about your question.

Actually I didn't plan to add such feature, but if you can upload source code to PasteBin or something like this and share a link, I'll try to officially add your feature.

Hope you're aware of this thread yet!