前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >bootstrap-table 前端分页,刷新事件代码实例

bootstrap-table 前端分页,刷新事件代码实例

作者头像
一个会写诗的程序员
发布2018-09-12 17:48:24
2.7K0
发布2018-09-12 17:48:24
举报
代码语言:javascript
复制
    function renderIssueTable(){
        $('#issueTable').bootstrapTable({
            detailView: false,//父子表
            //分页方式:client 客户端分页,server服务端分页(*)
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 50,
            pageList: [50, 100, 200, 300],
            paginationHAlign: 'right', //right, left
            paginationVAlign: 'bottom', //bottom, top, both
            paginationDetailHAlign: 'left', //right, left
            paginationPreText: '‹',
            paginationNextText: '›',
            searchOnEnterKey: false,
            strictSearch: false,
            searchAlign: 'right',
            selectItemName: 'btSelectItem',
            //是否显示搜索
            search: true,
            url: 'listIssueOfRecent6Month',
            method: 'GET',
            striped: true,      //是否显示行间隔色
            cache: false,      //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
            pagination: true,     //是否显示分页(*)
            paginationLoop: false,
            silent: true,
            //是否启用排序
            sortable: true,
            sortName: 'deptName',
            //排序方式
            sortOrder: "asc",
            contentType: 'application/json',
            dataType: 'json',
            // dataField: 'departmentIssueQualityDataList', //server 后端 : json 对应的表格数据 key
            responseHandler: function (res) {
                console.log(res)
                $('#issueTable').bootstrapTable('getOptions').data = res.result;
                return res;
            },
            // 缺陷创建时间(年月日)、缺陷ID、缺陷解决者、项目名称、所属产品线、深度、reopen次数、缺陷修复时长(取fixed_duration )、严重程度、缺陷状态、缺陷标题
            columns: [
                {
                    title: 'ID',
                    field: 'aoneIssueId',
                    align: 'left',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        var url = `https://aone.com/issue/${value}`;
                        return `<a href="${url}" target="_blank">${value}</a>`;
                    }
                },
                {
                    title: '标题',
                    field: 'subject',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        return value;
                    }
                },
                {
                    title: '状态',
                    field: 'status',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        return value;
                    }
                },
                {
                    title: '项目',
                    field: 'aoneProjectId',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        var url = `https://aone.com/project/${value}`;
                        return `<a href="${url}" target="_blank">${value}</a>`;
                    }
                },
                {
                    title: '产品线',
                    field: 'aoneProductId',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        var url = `https://aone.com/project/${value}`;
                        return `<a href="${url}" target="_blank">${value}</a>`;
                    }
                },
                {
                    title: '修复时长(天)',
                    field: 'fixedDuration',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        if (value && value !== 0) {
                            value = (value/(60*60*24)).toFixed(2)
                        }
                        return value;
                    }
                },
                {
                    title: '解决者',
                    field: 'assignedToWorkno',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        var url = `https://aone.com/${value}`;
                        return `<a href="${url}" target="_blank">${value}</a>`;
                    }
                }, {
                    title: '严重程度',
                    field: 'seriousLevel',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        return value;
                    }
                }, {
                    title: 'reopen次数',
                    field: 'reopenTimes',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        return value
                    }
                }, {
                    title: '发现深度',
                    field: 'depth',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    formatter: (value, row, index) => {
                        return value
                    }
                }, {
                    title: '部门',
                    field: 'deptFullName',
                    align: 'center',
                    valign: 'middle',
                    sortable : true,
                    cellStyle: function (value, row, index) {
                        return {
                            css: {
                                "min-width": "100px",
                                "word-wrap": "break-word",
                                "word-break": "normal"
                            }
                        };
                    },
                    formatter: (value, row, index) => {
                        return value
                    }
                }
            ],
            queryParams: function (params) {
                params.deptNo = $("#searchDept").select2("val");
                return params
            },
            // 当表格加载完毕才可以绑定的事件
            onPostBody: (rows) => {

            }
        });
        $('#issueTable').bootstrapTable('refresh');
    }

参考文档: http://bootstrap-table.wenzhixin.net.cn/

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.08.30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档