How to open dialog or popup when clicking on a cell in Dojo Dgrid

馋奶兔 提交于 2019-12-25 12:33:51

问题


I want to open a dialog box when clicking on a cell.I am using dgrid/editor.

      editor({field: "column1",label: "col1",editor: "text",editOn: "click"})

I am getting text box when using the above code.I want a dialog box.Please tell me how to get a dialog box.I am using OndemandGrid with JSONReststore to display the grid.


回答1:


You don't need use editor to trigger a dialog, use click event on a cell is ok:

   var grid = new declare([OnDemandGrid,Keyboard, Selection])({ 
        store: Observable(new Memory({data: []}))
    }, yourGridConatiner);

    grid.on(".dgrid-content .dgrid-cell:click", function (evt) {
        var cell = grid.cell(evt);
        var data = cell.row.data;

         /* your dialog creation at here, for example like below */
        var dlg = new Dialog({
            title: "Dialog",
            className:"dialogclass",
            content: dlgDiv  //you need create this div using dojo.create or put-selector
        });

        dlg.show();


    });

If you want show a pointer while mouse over that cell, you can style it at renderCell method with "cursor:pointer"




回答2:


From the wiki:

editor - The type of component to use for editors in this column; either a string specifying a type of standard HTML input to create, or a Dijit widget constructor to instantiate.

You could provide (to editor) a button that pops up a dialog when clicked, but that would probably mean two clicks to edit a cell: one to focus or enter edit mode or otherwise get the button to appear and one to actually click the button.

You could also not bother with the editor plugin and attach a click event handler to the cell and pop up a dialog from there. You would have to manually save the changes back to your store if you went that route.




回答3:


If I understand you right - you could try something like this:

function cellFormatter1(value) {
    //output html-code to open your popup - ie. using value (of cell) 

}

......

{field: "column1",label: "col1", formatter: cellFormatter1 }


来源:https://stackoverflow.com/questions/18917092/how-to-open-dialog-or-popup-when-clicking-on-a-cell-in-dojo-dgrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!