本文将介绍在代码和XML配置中的修改,支持表格的单选功能。
先自定义一个widget,继承平台默认的table
@SPI.ClassFactory(
BaseElementWidget.Token({
viewType: ViewType.Table,
widget: 'MyRadioTable'
})
)
export class MyRadioTable extends TableWidget {
@Widget.Reactive()
protected get selectMode(): ListSelectMode {
return ListSelectMode.radio;
}
}
注册layout
如果当前是主表格,那么xml配置如下
const xml = `<view type="TABLE">
<pack widget="group">
<view type="SEARCH">
<element widget="search" slot="search" slotSupport="field" />
</view>
</pack>
<pack widget="group" slot="tableGroup">
<element widget="actionBar" slot="actionBar" slotSupport="action">
<xslot name="actions" slotSupport="action" />
</element>
<element widget="MyRadioTable" slot="table" slotSupport="field">
<element widget="expandColumn" slot="expandRow" />
<element widget="RadioColumn" />
<xslot name="fields" slotSupport="field" />
<element widget="rowActions" slot="rowActions" slotSupport="action" />
</element>
</pack>
</view>`
registerLayout(xml, {
moduleName: '模块名称',
model: '模型',
viewType: ViewType.Table
})
如果当前的表格是form表单页面的表格,那么xml配置如下
const xml = `<view type="TABLE">
<view type="SEARCH">
<element widget="search" slot="search" slotSupport="field" />
</view>
<element widget="actionBar" slot="actionBar" slotSupport="action">
<xslot name="actions" slotSupport="action" />
</element>
<element widget="MyRadioTable" slot="table">
<element widget="expandColumn" slot="expandRow" />
<element widget="RadioColumn" />
<xslot name="fields" slotSupport="field" />
<element widget="rowActions" slot="rowActions" />
</element>
</view>`
registerLayout(xml, {
moduleName: '模块名称',
model: '模型',
viewType: ViewType.Table
})
Oinone社区 作者:汤乾华原创文章,如若转载,请注明出处:https://doc.oinone.top/frontend/4769.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验