dojo drop down button inside jquery ui dialog

2019-08-29 02:31发布

问题:

i placed dojo drop down button inside jquery ui dialog. The drop down list of button doesn't show in the jquery ui dialog, but dojo button is created. i tride by setting z-index more than 1000. do you have any suggesstion for this problem.

here is my code

  //links for dojo library
 <script type="text/javascript">


//beginning of TraderView(CDS) Actions Button

require(["dojo/ready", "dijit/form/DropDownButton", "dijit/DropDownMenu", "dijit/MenuItem", "dojo/dom"], function (ready, DropDownButton, DropDownMenu, MenuItem, dom) {
    ready(function () {

        //for document
        var menu = new DropDownMenu();
        var menuItem1 = new MenuItem({
            label: "Export to Excel",

            onClick: function () { alert('Export to Excel'); }
        });
        menu.addChild(menuItem1);

        var menuItem2 = new MenuItem({
            label: "Export to PDF",
            onClick: function () { alert('Export to PDF'); }
        });

        menu.addChild(menuItem2);

        var menuItem3 = new MenuItem({
            label: "Term Sheet",
            onClick: function () { alert('Term Sheet'); }
        });

        menu.addChild(menuItem3);

        var button = new DropDownButton({
            label: "Document",
            name: "dcment",
            dropDown: menu,
            id: "tvButton"
        });

        dom.byId("dropDownButtonDc").appendChild(button.domNode);



      });


   });


//end of TraderView(CDS) Actions Button
 </script>

回答1:

Popup z-index is calculated for every popup because you can open a popup from popup and that child popup ought to be above the parent popup. What you can do is to setup _beginZIndex of dijit/popup aka PopupManager - i.e. the value of the very first popup - the value of 1005 worked fine for me with jQuery UI dialog.

A working jsFiddle example: http://jsfiddle.net/phusick/q8V58/

EDIT: z-index: 1005 does not seem to be enough after the dialog is DnD moved, so I put there 10000 to be safe.

require([
    "dojo/ready",
    "dojo/dom",
    "dijit/popup",
    "dijit/form/DropDownButton",
    "dijit/DropDownMenu",
    "dijit/MenuItem"
], function(
    ready,
    dom,
    PopupManager,
    DropDownButton,
    DropDownMenu,
    MenuItem
) {

    ready(function() {

        // set z-index
        PopupManager._beginZIndex = 1005;

        var menu = new DropDownMenu();
        var menuItem1 = new MenuItem({
            label: "Export to Excel",
            onClick: function () { alert('Export to Excel'); }
        });

        var menuItem2 = new MenuItem({
            label: "Export to PDF",
            onClick: function () { alert('Export to PDF'); }
        });

        var menuItem3 = new MenuItem({
            label: "Term Sheet",
            onClick: function () { alert('Term Sheet'); }
        });

        menu.addChild(menuItem1);
        menu.addChild(menuItem2);
        menu.addChild(menuItem3);

        var button = new DropDownButton({
            label: "Document",
            name: "dcment",
            dropDown: menu,
            id: "tvButton"
        });

        button.startup();
        button.placeAt(dom.byId("dropDownButtonDc"));

        $("#dialog1").dialog({ title: "dialog1"});

    }); 
});​