, cols: [[ { title: '编号', type: 'numbers', width:50, fixed: 'left' } , { field: 'river_status', title: '事件种类', width:150, align: 'center', , { field: 'event_no', title: '事件编号', width:280, align: 'center' } , { field: 'supervise_no', title: '督办单号', width:180, align: 'center' } , { field: 'describe', title: '事件内容', align: 'center' } , { field: 'supervise_topic', title: '督办标题', width:200, align: 'center' } , { field: 'create_time', title: '督办时间', width:150, align: 'center' } , { field: 'receive_user_name', title: '责任人员/单位',width:120, align: 'center' } , { field: 'user_name', title: '发起人员', width:90, align: 'center' } , { field: 'status', title: '状态', width:80, align: 'center', } , { toolbar: '#barDemo', title: '操作', width:160, align: 'center' } ]]river_status值为0展示河流事件值为1展示湖泊事件
时间: 2024-01-10 20:03:39 浏览: 132
根据您的描述,您想要在表格中展示不同类型的事件,其中 `river_status` 字段的值为0时展示河流事件,值为1时展示湖泊事件。根据您提供的代码片段,可以对 `field: 'river_status'` 进行修改,使用 formatter 函数来根据字段的值进行条件判断。
以下是修改后的代码示例:
```javascript
cols: [[
{ title: '编号', type: 'numbers', width: 50, fixed: 'left' },
{
field: 'river_status',
title: '事件种类',
width: 150,
align: 'center',
formatter: function(value, row, index) {
if (value === 0) {
return '河流事件';
} else if (value === 1) {
return '湖泊事件';
} else {
return '';
}
}
},
{ field: 'event_no', title: '事件编号', width: 280, align: 'center' },
{ field: 'supervise_no', title: '督办单号', width: 180, align: 'center' },
{ field: 'describe', title: '事件内容', align: 'center' },
{ field: 'supervise_topic', title: '督办标题', width: 200, align: 'center' },
{ field: 'create_time', title: '督办时间', width: 150, align: 'center' },
{ field: 'receive_user_name', title: '责任人员/单位', width: 120, align: 'center' },
{ field: 'user_name', title: '发起人员', width: 90, align: 'center' },
{ field: 'status', title: '状态', width: 80, align: 'center' },
{ toolbar: '#barDemo', title: '操作', width: 160, align: 'center' }
]]
```
在上述代码中,我们在 `field: 'river_status'` 的列中添加了 formatter 函数,根据字段的值进行条件判断,如果值为0,则返回"河流事件",如果值为1,则返回"湖泊事件",否则返回空字符串。
希望对您有所帮助!如果您还有其他问题,请随时提问。
阅读全文
相关推荐


















在这个代码添加一个表格列,类型为score,标题为热点,宽度为200,不可编辑,排序。放在列"访问路径"的右边:table.render({ elem: '#test' ,url:'/xlSpider/getDataFromDB' ,where:{"keyword":$("#keyword").val()} ,toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板 ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可 title: '提示' ,layEvent: 'LAYTABLE_TIPS' ,icon: 'layui-icon-tips' }] ,id: 'testReload' ,title: '爬取内容结果' ,cols: [[ {type: 'checkbox', fixed: 'left'} ,{field:'id', title:'排名', width:200, fixed: 'left', unresize: true, sort: true} ,{field:'content', title:'内容', width:300, edit: 'text'} ,{field:'url', title:'访问路径', width:300, edit: 'text',templet: function(res){ return ''+ res.url +'' } } ]] ,page: true });

