You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# user-table-custom-attribute
|
|
|
|
|
|
|
|
拓展用户管理表格,新增属性列
|
|
|
|
|
|
|
|
## 代码示例
|
|
|
|
```
|
|
|
|
BI.config("dec.provider.all_user", function (provider) {
|
|
|
|
provider.inject({
|
|
|
|
extraAttributes: [
|
|
|
|
{
|
|
|
|
header: "婚姻状况", // 表头属性,默认是label组件
|
|
|
|
// header: { // 也可以传入自定义组件
|
|
|
|
// type: "xxx",
|
|
|
|
// },
|
|
|
|
attributeGetter: function (users, cb) { // 注入用户额外属性的回调函数,接受完整的当前页用户信息
|
|
|
|
setTimeout(function () { // 模拟异步请求
|
|
|
|
BI.each(users, function (index, user) {
|
|
|
|
user.maritalSstatus = ["已婚", "未婚", "丧偶", "合法同居"][index % 4];
|
|
|
|
});
|
|
|
|
cb();
|
|
|
|
}, 200);
|
|
|
|
},
|
|
|
|
width: 50, // 列宽
|
|
|
|
// column: "xxx", // 每一行对应的列元素组件,会传递所有用户信息options
|
|
|
|
column: function (userInfo) { // 列元素的组件回调,接受注入后的用户信息,返回组件
|
|
|
|
return {
|
|
|
|
type: "bi.label",
|
|
|
|
textAlign: "left",
|
|
|
|
text: userInfo.maritalSstatus,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
## 效果演示
|
|
|
|
![](./screenshots/demo.png)
|