创建下拉单元格,因为下拉选项是调用接口获取的,为更好的用户体验,表格首次创建时 下拉选项设为空‘const verticalStyle = new GC.Spread.Sheets.Style();
verticalStyle.cellButtons = [
{
imageType: GC.Spread.Sheets.ButtonImageType.dropdown,
command: 'openList',
useButtonStyle: false,
enabled: true
}
];
verticalStyle.dropDowns = [
{
type: GC.Spread.Sheets.DropDownType.list,
option: {
multiSelect: false,
items: []
}
}
];
sheet.setStyle(rowIdx, colIdx, verticalStyle);
点击倒三角按钮时,监听buttonClicked事件,调用后台接口,获取下拉选项列表,再次执行上述方法,设置options
setTimeout(() => {
const options = [
{ text: 'a', value: 0 },
{ text: 'b', value: 1 }
];
const verticalStyle = new GC.Spread.Sheets.Style();
verticalStyle.cellButtons = [
{
imageType: GC.Spread.Sheets.ButtonImageType.dropdown,
command: 'openList',
useButtonStyle: false,
enabled: true
}
];
verticalStyle.dropDowns = [
{
type: GC.Spread.Sheets.DropDownType.list,
option: {
multiSelect: false,
items: options
}
}
];
sheet.setStyle(rowIdx, colIdx, verticalStyle);
}, 5000);
然后我再次点击倒三角按钮,下拉列表不显示。然后我随意点击其他单元格,然后再点击倒三角按钮,下拉选项才会展示。
感觉是有个开关
有什么办法可以解决吗?
|
|