阅读该文档的前置条件
1.前端自定义表格组件
import { ActiveRecord, BaseElementWidget, Condition, Entity, SPI, TableWidget, ViewType } from '@kunlun/dependencies';
@SPI.ClassFactory(
BaseElementWidget.Token({
type: ViewType.Table,
widget: ['demo-tree-table']
})
)
export class TreeTableWidget extends TableWidget {
// 默认展开所有层级
protected getTreeExpandAll() {
return true;
}
// 关闭懒加载
protected getTreeLazy(): boolean {
return false;
}
public async $$loadTreeNodes(condition?: Condition, currentRow?: ActiveRecord): Promise<Entity[]> {
// 树表加载数据的方法,默认首次只查第一层的数据,这里去掉这个查询条件的参数condition,这样就会查所有层级数据
return super.$$loadTreeNodes(undefined, currentRow);
}
}
2. 注册layout
import { registerLayout, ViewType } from '@kunlun/dependencies';
const install = () => {
registerLayout(
`
<view type="TABLE">
<element widget="actionBar" slot="actionBar" slotSupport="action">
<xslot name="actions" slotSupport="action" />
</element>
<element widget="demo-tree-table" slot="table">
<element widget="expandColumn" slot="expandRow" />
<xslot name="fields" slotSupport="field" />
<element widget="rowActions" slot="rowActions" slotSupport="action" />
</element>
</view>
`,
{
viewType: ViewType.Table,
model: "resource.resourceCity", // 变量,需要替换
actionName: "MenuuiMenu6f6005bdddba468bb2fb814a62fa83c6", // 变量,需要替换
}
);
};
install();
Oinone社区 作者:nation原创文章,如若转载,请注明出处:https://doc.oinone.top/frontend/16149.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验