【问题标题】:id for buttons in datagrid数据网格中按钮的 ID
【发布时间】:2012-08-31 07:11:25
【问题描述】:

我有以下代码用于在 DataGrid 的每一行中添加按钮:

structure: [
    {field: 'msConstId', width: '0%', name: 'Milestone',hidden: true},
    {field: 'edit', width: '8%', name: 'Edit',formatter: function(data, rowIndex) { 
         return new dijit.form.Button({style: "width: 80px;",label:"Edit", iconClass:"dijitIconEditTask",showLabel:true, onClick:function(){    updateMilestone.show(); populateUpdateControls(); }});
    }},
    {field: 'delete', width: '10%', name: 'Delete',formatter: function(data, rowIndex) {
         return new dijit.form.Button({style: "width: 80px;",label:"Delete", iconClass:"dijitIconDelete",showLabel:true, onClick:function(){    deleteMilestoneDialog(); }});
    }}
]

问题是我想为每个按钮分配一个 id 作为“editBtnRowIndex”和“deleteBtnRowIndex”。我想使用 id 来启用和禁用特定网格行中的按钮。

这可能吗?

【问题讨论】:

    标签: dojo dojox.grid.datagrid


    【解决方案1】:

    我不得不通过查看其他字段中的数据并使用以下内容禁用该行的按钮来解决此问题:

    var rowdata = grid.getItem(rowIndex);
    

    rowIndex 作为参数传递给格式化函数。

    var val = rowdata.myRowID;
    if(val=='specific value') {
       //return disabled button
    } else {
       //return enabled button
    }
    

    【讨论】:

      猜你喜欢
      • 2012-07-28
      • 1970-01-01
      • 1970-01-01
      • 2012-08-15
      • 2020-12-10
      • 2018-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多