Kendo ui kendo pivotgrid行和列展开始终为false
我正在尝试保存PivotGrid状态以备将来加载。我有两个问题 1:行项目的展开属性在运行时未更改。此处测试:当用户在运行时展开项时,返回的row by dataSource.rows()的expand属性与初始化时的属性相同Kendo ui kendo pivotgrid行和列展开始终为false,kendo-ui,Kendo Ui,我正在尝试保存PivotGrid状态以备将来加载。我有两个问题 1:行项目的展开属性在运行时未更改。此处测试:当用户在运行时展开项时,返回的row by dataSource.rows()的expand属性与初始化时的属性相同 2:我找不到一种方法来使用“要包括的字段”菜单以及行、列和度量值来保存/加载所选的字段(切片)。我正在React中工作,但您应该能够执行类似的操作 这是一个bug,要解决它,您可以侦听expandMember和collapseMember事件以手动跟踪扩展行/列的轴和路径
2:我找不到一种方法来使用“要包括的字段”菜单以及行、列和度量值来保存/加载所选的字段(切片)。我正在React中工作,但您应该能够执行类似的操作
createGrid=()=>{
$(`pivot grid`)。kendoPivotGrid({
数据源:{
数据:数据,
schema:schema,
columns:this.state.columns,
行:this.state.rows,
措施:本州措施,
过滤器:this.state.filter
},
expandMember:this.onExpand,
collapseMember:这个是.onCollapse
});
让网格=$(`pivot grid`)。数据('kendoPivotGrid');
如果(网格){
if(this.state.expanded){
this.state.expands.forEach(expand=>{
如果(expand.axis==='rows'){
grid.dataSource.expandRow(expand.path);
}否则{
grid.dataSource.expandColumn(expand.path);
}
});
}
$(`pivot config`).kendopivot配置程序({
数据源:grid.dataSource,
可过滤:真
});
}
//展开configurator字段中的项目。
let tree=$('.k-treeview').data('kendoTreeView');
如果(树){
展开('.k-item');
}
};
onExpand=e=>{
这是我的国家({
扩展:[…this.state.expansions{
轴:e轴,
路径:e.path
}]
});
};
onCollapse=e=>{
这是我的国家({
扩展:this.state.expanses.filter(ex=>ex.axis!==e.axis&&JSON.stringify(ex.path)!==JSON.stringify(e.path))
});
};代码>这是我的试穿
我喜欢的是,它实际上会像您所期望的那样更新数据源
function onExpandOrCollapseMember(e, expand) {
var pivot = e.sender;
var axisToUpdate = '_' + e.axis;
var field = _.find(pivot.dataSource[axisToUpdate], f => JSON.stringify(f.name) === JSON.stringify(e.path));
field.expand = expand;
}
在我传递的轴选项上
expandMember: e => onExpandOrCollapseMember(e,true),
collapseMember: e => onExpandOrCollapseMember(e, false),