VTable
VTable copied to clipboard
[Feature] 增加类似于 `getCellOriginRecord` 的 `getCellOriginColumn` API,以用于获取配置中的表列
What problem does this feature solve?
现有的表格API中没有一个现成的类似于当前请求的API的功能,只能通过以下方式进行获取:
tableInstance.options.columns[col]
而如果在项目中需要进行自定义编辑器开发的时候会时常需要获取到当前表列的配置,如果这使得项目中会出现非常多重复的代码,并且每次调用的时候都需要手动处理索引的边界情况
What does the proposed API look like?
// method call
tableInstance.getCellOriginColumn(0)
tableInstance.getCellOriginColumn([3, 0])
full example:
let tableInstance;
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data.json')
.then(res => res.json())
.then(data => {
const columns = [
{
field: 'Order ID',
title: 'Order ID',
width: 'auto',
columns: [
{ field: 'aaa', title: 'aaa' },
{ field: 'bbb', title: 'bbb' }
]
},
{
field: 'Customer ID',
title: 'Customer ID',
width: 'auto'
}
];
const option = {
records: data,
columns,
widthMode: 'standard'
};
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window.tableInstance = tableInstance;
console.log(tableInstance.getCellOriginColumn(1));
console.log(tableInstance.getCellOriginColumn([0, 1]));
});
有个api可以获取列,getBodyColumnDefine(col: number, row: number)
有个api可以获取列,getBodyColumnDefine(col: number, row: number)
感谢,如果不是你我都不知道有这个API,文档上没有写,代码里也不知道该搜索什么
有个api可以获取列,getBodyColumnDefine(col: number, row: number)
感谢,如果不是你我都不知道有这个API,文档上没有写,代码里也不知道该搜索什么
不客气~ 可以引入 Vtable 类型 ,VTable.ListTable | VTable.PivotTable | VTable.PivotChart,然后根据实例的输入提示来查找使用