想法是在单击按钮时更改网格中第一列的标签和工具提示。当我点击按钮时,加载了正确的数据,设置了新的工具提示(" ChangedTooltip")但是列的标签仍然相同("主要"而不是& #34; ChangedLabel&#34)。我错过了什么,或者方法是错的?如何在列的标签中设置新值?
两个.js:Principal.js和PrincipalTable.js
Principal.js
...
/**
* add events to select button
*/
var createEventForSelectButton = function(year, period) {
on(selectButton, "click", function(event) {
currentQueryMap = initQueryMap(year, period);
grid.setFirstColumn(period.value); <-- IMPORTANT!!!!!
grid.set('query', currentQueryMap);
});
};
...
return declare([], {
...
grid = new PrincipalTable(...);
PrincipalTable.js
var grid = declare([ SortFormatterGrid, Selection ], {
constructor : function(args) {
...
this.columns = [ {
label : "principal",
field : "id",
sortFormatter : function(object) {
return object;
},
tooltip : "principal"
}, {
...
},
setFirstColumn : function() { <-- IMPORTANT!!!!
this.columns[0].label= "ChangedLabel";
this.columns[0].tooltip= "ChangedTooltip";
}
});
答案 0 :(得分:1)
让dgrid重建列:this.set(&#34; columns&#34;,this.columns)