未调用网格列渲染器
Grid Column Renderer not called
我遇到一个问题,即在使用过滤插件时未调用集会网格列渲染。
第一次进入页面时,它工作正常,甚至是过滤。但是,如果我进行页面刷新(浏览器 F5 或转到另一个页面并返回),则不会调用渲染器函数。
这是错误还是功能?
我能否以某种方式强制调用渲染器函数,例如,在商店加载事件中?
这是一个展示行为的小例子;
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function () {
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['PortfolioItem/Initiative'],
enableHierarchy: true
}).then({
success: this._onStoreBuilt,
scope: this
});
},
_onStoreBuilt: function (store) {
var modelNames = ['PortfolioItem/Initiative'];
var context = this.getContext();
this.add({
xtype: 'rallygridboard',
context: context,
modelNames: modelNames,
toggleState: 'grid',
plugins: [
'rallygridboardaddnew',
{
ptype: 'rallygridboardfieldpicker',
headerPosition: 'left',
modelNames: modelNames,
stateful: true,
stateId: context.getScopedStateId('grid-fields')
},
{
ptype: 'rallygridboardinlinefiltercontrol',
inlineFilterButtonConfig: {
stateful: true,
stateId: context.getScopedStateId('grid-filters'),
modelNames: modelNames,
inlineFilterPanelConfig: {
quickFilterPanelConfig: {
defaultFields: [
'ArtifactSearch',
'State'
]
}
}
}
}
],
gridConfig: {
store: store,
columnCfgs: [
'Name',
'State',
{
text: 'Refined',
dataIndex: 'RefinedEstimate',
renderer: function (value) {
console.log("RefinedEstimate:renderer");
return value + " EUR";
}
}
]
},
height: this.getHeight()
});
}
});
如果在 gridconfig 中将 alwaysShowDefaultColumns 设置为 true 会怎么样?
gridConfig: {
alwaysShowDefaultColumns: true
}
我一直在尝试不同的选项,实际上我认为它与网格板有关,而不是插件。
我创建了一个相当简单的网格板,我可以在上面重现该问题。
复制步骤;
- 创建新页面
- 插入HTML应用+粘贴代码
- 重新排列列顺序
- 刷新页面 (F5) 或跳转到另一个页面并返回
现在不再调用自定义渲染器函数。
我用 rallygrid 做了同样的尝试,但这里的渲染效果很好。
基本的 RallyGrid 代码
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function () {
console.log("launch()");
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['PortfolioItem/Initiative'],
autoLoad: true,
enableHierarchy: true
}).then({
success: this._onStoreBuilt,
scope: this
});
},
_onStoreBuilt: function (store) {
console.log("_onStoreBuilt()");
var modelNames = ['PortfolioItem/Initiative'];
var context = this.getContext();
var me = this;
var myGrid = me.add({
xtype: 'rallygridboard',
context: context,
modelNames: modelNames,
toggleState: 'grid',
gridConfig: {
store: store,
alwaysShowDefaultColumns: true,
columnCfgs: [
'Name',
'State',
{
text: 'Refined',
dataIndex: 'RefinedEstimate',
renderer: function (value) {
console.log("RefinedEstimate:renderer");
return value + " EUR";
}
},
{
text: 'Department (Yrs)',
xtype: 'templatecolumn',
tpl: '{RefinedEstimate} ({Name})'
}
]
},
height: me.getHeight()
});
}});
问题似乎是您没有获取要显示的字段。
如果您在首次构建 TreeStore 时未指定 'fetch' 列表,则 SDK 将恢复为默认字段集(即不是所有字段)。做grid的时候,字段不存在,所以取不到数据,也就懒得去调用renderer了
如果你在enableHierarchy后面加上一行"fetch: true",估计就活灵活现了。如果您不想获取所有字段,请指定要获取的字段数组。例如:
提取:['FormattedID'、'ObjectID'、'RefinedEstimate'、'PreliminaryEstimate']
我已经确认这是一个错误。
由于专注于使用 React 的新框架,可能不会被优先考虑。
我遇到一个问题,即在使用过滤插件时未调用集会网格列渲染。
第一次进入页面时,它工作正常,甚至是过滤。但是,如果我进行页面刷新(浏览器 F5 或转到另一个页面并返回),则不会调用渲染器函数。
这是错误还是功能?
我能否以某种方式强制调用渲染器函数,例如,在商店加载事件中?
这是一个展示行为的小例子;
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function () {
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['PortfolioItem/Initiative'],
enableHierarchy: true
}).then({
success: this._onStoreBuilt,
scope: this
});
},
_onStoreBuilt: function (store) {
var modelNames = ['PortfolioItem/Initiative'];
var context = this.getContext();
this.add({
xtype: 'rallygridboard',
context: context,
modelNames: modelNames,
toggleState: 'grid',
plugins: [
'rallygridboardaddnew',
{
ptype: 'rallygridboardfieldpicker',
headerPosition: 'left',
modelNames: modelNames,
stateful: true,
stateId: context.getScopedStateId('grid-fields')
},
{
ptype: 'rallygridboardinlinefiltercontrol',
inlineFilterButtonConfig: {
stateful: true,
stateId: context.getScopedStateId('grid-filters'),
modelNames: modelNames,
inlineFilterPanelConfig: {
quickFilterPanelConfig: {
defaultFields: [
'ArtifactSearch',
'State'
]
}
}
}
}
],
gridConfig: {
store: store,
columnCfgs: [
'Name',
'State',
{
text: 'Refined',
dataIndex: 'RefinedEstimate',
renderer: function (value) {
console.log("RefinedEstimate:renderer");
return value + " EUR";
}
}
]
},
height: this.getHeight()
});
}
});
如果在 gridconfig 中将 alwaysShowDefaultColumns 设置为 true 会怎么样?
gridConfig: {
alwaysShowDefaultColumns: true
}
我一直在尝试不同的选项,实际上我认为它与网格板有关,而不是插件。
我创建了一个相当简单的网格板,我可以在上面重现该问题。
复制步骤;
- 创建新页面
- 插入HTML应用+粘贴代码
- 重新排列列顺序
- 刷新页面 (F5) 或跳转到另一个页面并返回
现在不再调用自定义渲染器函数。
我用 rallygrid 做了同样的尝试,但这里的渲染效果很好。
基本的 RallyGrid 代码
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function () {
console.log("launch()");
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['PortfolioItem/Initiative'],
autoLoad: true,
enableHierarchy: true
}).then({
success: this._onStoreBuilt,
scope: this
});
},
_onStoreBuilt: function (store) {
console.log("_onStoreBuilt()");
var modelNames = ['PortfolioItem/Initiative'];
var context = this.getContext();
var me = this;
var myGrid = me.add({
xtype: 'rallygridboard',
context: context,
modelNames: modelNames,
toggleState: 'grid',
gridConfig: {
store: store,
alwaysShowDefaultColumns: true,
columnCfgs: [
'Name',
'State',
{
text: 'Refined',
dataIndex: 'RefinedEstimate',
renderer: function (value) {
console.log("RefinedEstimate:renderer");
return value + " EUR";
}
},
{
text: 'Department (Yrs)',
xtype: 'templatecolumn',
tpl: '{RefinedEstimate} ({Name})'
}
]
},
height: me.getHeight()
});
}});
问题似乎是您没有获取要显示的字段。
如果您在首次构建 TreeStore 时未指定 'fetch' 列表,则 SDK 将恢复为默认字段集(即不是所有字段)。做grid的时候,字段不存在,所以取不到数据,也就懒得去调用renderer了
如果你在enableHierarchy后面加上一行"fetch: true",估计就活灵活现了。如果您不想获取所有字段,请指定要获取的字段数组。例如: 提取:['FormattedID'、'ObjectID'、'RefinedEstimate'、'PreliminaryEstimate']
我已经确认这是一个错误。
由于专注于使用 React 的新框架,可能不会被优先考虑。