2012-08-31 41 views
0

按鈕,我已經爲在DataGrid有史以來排將按鈕添加以下代碼:ID在數據網格

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來啓用和禁用特定網格行中的按鈕。

這可能嗎?

回答

0

我不得不尋找其他領域的數據和這樣的禁用按鈕,該行與工作圍繞這個去:

var rowdata = grid.getItem(rowIndex); 

的rowIndex爲參數去格式化功能傳遞。

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