【问题标题】:show text and a button in dojo EnhancedGrid在 dojo EnhancedGrid 中显示文本和按钮
【发布时间】:2014-08-08 21:05:57
【问题描述】:

我有一个道场增强网格,我正在使用格式化程序在其中一列中显示一个按钮

 {field: '_item', name: 'Update Data', formatter: dojo.hitch(context, this.getUpdateData), width: '165px' },




getUpdateData: function(rowItem) {      
        var button = new dijit.form.Button({
            label: '<img src="/public/img/icon_texteditor.png" height="19px" width="19px"/>',
            onClick: function(){
                alert('hi');
            }
        });         
        return button;              
    }

这很好用。该按钮已正确呈现,当我单击它时,它会正确显示警报对话框。我想做的是显示一些文本/标签,然后是网格单元格中的按钮。我尝试在格式化程序中创建一个 div 并尝试将按钮添加到 div:

getUpdateData: function(rowItem) { 
        var divNode = dojo.create("div", { innerHTML: rowItem.someText });
        var button = new dijit.form.Button({
            label: '<img src="/public/img/icon_texteditor.png" height="19px" width="19px"/>',
            onClick: function(){
                alert('hi');
            }
        });

        button.placeAt(divNode);
        return divNode.innerHTML;
    }

即使它正确呈现(文本显示在表格中的按钮之前),当我点击按钮时,什么也没有发生。未调用 onClick 事件处理程序。

我的问题是:如何在网格单元格中显示一些文本+按钮。

【问题讨论】:

    标签: button dojo grid


    【解决方案1】:

    这对我有用:

    getUpdateData: function(rowItem) {   
     var cpane = new dojox.layout.ContentPane (
            content: rowItem.someText;
     });
    
     var button = new dijit.form.Button({
                label: '<img src="/public/img/icon_texteditor.png" height="19px"  width="19px"/>',
                onClick: function(){
                    alert('hi');
                }
            });
    
    
     button.placeAt (cpane);
     return cpane;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-18
      • 1970-01-01
      • 2012-08-03
      • 1970-01-01
      相关资源
      最近更新 更多