我爲此創建了一個自定義插件。關鍵的部分是renderCell功能:
define([
"dojo",
"sb",
"put-selector/put",
"dgrid/editor",
"dijit/form/Select"
], function(dojo, sb, put, editor, Select){
dojo.global.starbug.grid.columns = dojo.global.starbug.grid.columns || {};
dojo.global.starbug.grid.columns.select = function(column){
//populate the cell with the label or value
column.renderCell = function(object, value, cell, options, header){
items = column.editorInstance.getOptions();
for (var i in items) {
if (value == items[i].value) value = items[i].label;
}
put(cell, 'span.'+value.replace(/ /g, '-').toLowerCase(), value);
};
column.editorArgs = {
style:'width:100%',
labelAttr:'label',
store:sb.get(column.from, 'select')
};
column = editor(column, Select, "dblclick");
return column;
};
});
注意sb
是我用來提供商店的自定義模塊。您可以相應地修改它。
您應該讓問題的標題更具信息性,併爲您的帖子添加更多標籤,例如'javascript','dojo'和'dgrid' – 2013-04-14 21:12:19