列插件(树)在dojo中捕获单击事件

时间:2012-11-19 11:21:09

标签: javascript dojo mouseevent dgrid

我有一个dgrid,如下面的代码,我的第二个字段是树,我需要在用户点击树的图标时调用XHR。我怎么能抓住这个事件?

谢谢

        var CustomGrid = declare([OnDemandGrid, Keyboard, Selection, Pagination]); 

        var grid = new CustomGrid({ 
            columns: [ 
                selector({label: "#", disabled: function(object){ return object.type == 'DOCx'; }}, "radio"), 
                {label:'Id', field:'id', sortable: false}, 
                tree({label: "Title", field:"title", sortable: false, indentWidth:20}), 
                {label:'Count', field:'count', sortable: false} 
            ], 
            store: memoryStore, 
            pagingLinks: false, 
            pagingTextBox: true, 
            firstLastArrows: true, 
            pageSizeOptions: [10, 15, 25], 
            selectionMode: "single", // for Selection; only select a single row at a time 
            cellNavigation: false // for Keyboard; allow only row-level keyboard navigation 
        }, "grid"); 

1 个答案:

答案 0 :(得分:0)

我找到了解决dojo代码的解决方案。 dgrid / util 中有一个名为 mouse.js 的文件,您可以在其中找到其他示例:

enterRow: handler(".dgrid-content .dgrid-row", "mouseover"),
        enterCell: handler(".dgrid-content .dgrid-cell", "mouseover"),
        enterHeaderCell: handler(".dgrid-header .dgrid-cell", "mouseover"),
        leaveRow: handler(".dgrid-content .dgrid-row", "mouseout"),
        leaveCell: handler(".dgrid-content .dgrid-cell", "mouseout"),
        leaveHeaderCell: handler(".dgrid-header .dgrid-cell", "mouseout"),

所以,就我的情况而言,我刚刚补充道:

clickCell: handler(".dgrid-content .dgrid-expando-icon", "click"),
dblclickCell: handler(".dgrid-content .dgrid-cell", "dblclick"),

现在,您可以在 dgrid / test 中的 Grid_mouseevents.html 中测试新事件。

问候。