bootstrapTable加入复选框checkbox后表单不显示数据

发布于 2022-09-06 22:30:16 字数 11174 浏览 28 评论 0

$(function () {

        $('#datagrid-2').bootstrapTable({
            loadMsg: '正在加载...',
            url: window.webapi + "/BridgeDaliyReport/DamageList",
            method: 'post',
            async: false,
            pagination: true,
            height: $(window).height() - $(".hei1").height() - $(".hei2").height() - 100,
            pageSize: 15,
            pageList: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
            clickToSelect: false,
            showColumns: true,
            minimumCountColumns: 2,
            clickToSelect: true,
            sidePagination: "server", //服务端处理分页
            queryParamsType: "limit",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json",

            columns: [
                //{
                //    field: "state",
                //    checkbox: true,
                //    align: 'center',
                //},
                { field: 'BRIDGENAME', title: '名称', sortable: true },
                { field: 'CheckName', title: '项目', sortable: true },
                {
                    field: 'CreateTime',
                    title: '时间',
                    sortable: true,
                    formatter: function (val) {
                        if (val)
                            return val.split("T")[0];
                        else return val;
                    }
                },
                { field: 'DefectDegreeName', title: '病害', sortable: true },

                {
                    field: 'State',
                    title: '状态',
                    sortable: true,
                    width: 200,
                    formatter: function (val, rowData, index) {
                        
                        if (val == 0) {
                            return "<input type='checkbox' checked='checked'>已结案</input>";
                        } else {
                            return "<input type='checkbox' >未结案</input>";
                        }
                    }
                },
                 {
                     field: 'CHECKDATE',
                     title: '结案时间',
                     sortable: true,
                     formatter: function (val, rowData, index) {
                         if (rowData.State != 0) return;
                         if (val)
                             return val.split("T")[0];
                         else return val;
                     }
                 },

                {
                    field: 'Description', title: '详情', sortable: true,
                    formatter: function (val, rowData, index) {
                        if (val == null || val == "undefined" || val == "无") val = "";
                        if (val == "") return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">详情</a>&nbsp;&nbsp;';
                        else return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">' + val + '</a>&nbsp;&nbsp;';
                    }
                }
            ],
            
            
            queryParams: function (params) {
                //var conck = $.trim($("th-inner checkbox").val());
                var searchString;
                if ($.trim($(".txt_search").val()) == $(".txt_search").attr("placeholder")) {
                    searchString = "";
                } else searchString = $(".txt_search").val().trim();
                var date;
                if ($.trim($(".datepicker").val()) == $(".datepicker").attr("placeholder")) {
                    date = "";
                } else date = $(".datepicker").val().trim();
                //检查项 病害值 状态
                var checkItem = [];
                $(".sickSearchItem li.selected.checkitem").each(function (index) {
                    checkItem.push($(this).data('id'));
                });
                var checknames = checkItem.join(",");
                var damageDegree = [];
                $(".sickSearchItem li.selected.damage").each(function (index) {
                    damageDegree.push($(this).text());
                });
                var damageDegree = damageDegree.join(",");

                var state = 3; //0 1 2

                if ($(".sickSearchItem li.selected.state").length == 1) {
                    if ($(".sickSearchItem li.selected.state").text() == "已结案") state = 0;
                    else state = 1;
                }

                var columns = [];
                $('#datagrid-2').find("thead tr th").each(function (index) {

                    var column = $(this).attr('data-field');
                    if (column != null || column != undefined || column != "") {
                        columns.push(column);
                    }
                });
                columns.push("ReportId");
                var columns = columns.join(",");
                var bridgeID = window.location.search.replace('?', '').split('=')[1];
                //var bridgeID = $(".id_search").val().trim();
                return {
                    pageNumber: params.offset / params.limit + 1,
                    pageSize: params.limit,
                    type: 2,
                    damageDegree: damageDegree,
                    bridgename: searchString,
                    date: date,
                    columns: columns,
                    checknames: checknames,
                    state: state,
                    bridgeID: bridgeID
                };
            }
            /**
            index父表当前行的行索引
            row:父表当前行的Json数据对象。
            $detail:当前行下面创建的新行里面的td对象。
            */

        });

        $('#datagrid-1').bootstrapTable({
            loadMsg: '正在加载...',
            url: window.webapi + "/BridgeDaliyReport/DamageList",
            method: 'post',
            async: false,
            pagination: true,
            height: $(window).height() - $(".hei1").height() - $(".hei2").height() - 100,
            pageSize: 15,
            pageList: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
            sidePagination: "server", //服务端处理分页
            queryParamsType: "limit",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json",
            columns: [
                  { field: 'BRIDGENAME', title: '桥梁名称', sortable: true },
                { field: 'CheckName', title: '检查项目', sortable: true },
                {
                    field: 'CreateTime',
                    title: '检查时间',
                    sortable: true,
                    formatter: function (val) {
                        if (val)
                            return val.split("T")[0];
                        else return val;
                    }
                },
                { field: 'DefectDegreeName', title: '病害', sortable: true },                    
                {
                    field: 'State',
                    title: '状态',                       
                    formatter: function (val)
                    {
                        if (val == 0) return "已结案";
                        else return "未结案";
                    }                        
                },

                 {
                     field: 'CHECKDATE',
                     title: '结案时间',
                     sortable: true,
                     formatter: function (val, rowData, index) {
                         if (rowData.State != 0) return;
                         if (val)
                             return val.split("T")[0];
                         else return val;
                     }
                 },
                {
                    field: 'Description', title: '详情', sortable: true,
                    formatter: function (val, rowData, index) {
                        if (val == null || val == "undefined" || val == "无") val = "";
                        if (val == "") return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail2()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">详情</a>&nbsp;&nbsp;';
                        else return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail2()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">' + val + '</a>&nbsp;&nbsp;';

                    }
                }
            ],
            queryParams: function (params) {
                var searchString;
                if ($.trim($(".txt_search").val()) == $(".txt_search").attr("placeholder")) {
                    searchString = "";
                } else searchString = $(".txt_search").val().trim();
                var date;
                if ($.trim($(".datepicker").val()) == $(".datepicker").attr("placeholder")) {
                    date = "";
                } else date = $(".datepicker").val().trim();
                //检查项 病害值 状态
                var checkItem = [];

                $(".sickSearchItem li.selected.checkitem1").each(function (index) {
                    checkItem.push($(this).data('id'));
                });
                var checknames = checkItem.join(",");
                var damageDegree = [];
                $(".sickSearchItem li.selected.damage").each(function (index) {
                    damageDegree.push($(this).text());
                });
                var damageDegree = damageDegree.join(",");

                var state = 3; //0 1 2
                if ($(".sickSearchItem li.selected.state").length == 1) {
                    if ($(".sickSearchItem li.selected.state").text() == "已结案") state = 0;
                    else state = 1;
                }

                var columns = [];
                $('#datagrid-1').find("thead tr th").each(function (index) {

                    var column = $(this).attr('data-field');
                    if (column != null || column != undefined || column != "") {
                        columns.push(column);
                    }
                });
                columns.push("ReportId");
                var columns = columns.join(",");


                var bridgeID = window.location.search.replace('?', '').split('=')[1];
                //var bridgeID = $(".id_search").val().trim();
                return {
                    pageNumber: params.offset / params.limit + 1,
                    pageSize: params.limit,
                    type: 1,
                    damageDegree: damageDegree,
                    bridgename: searchString,
                    date: date,
                    columns: columns,
                    checknames: checknames,
                    state: state,
                    bridgeID: bridgeID
                };
            }
            /**
            index父表当前行的行索引
            row:父表当前行的Json数据对象。
            $detail:当前行下面创建的新行里面的td对象。
            */

        });
    });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情仇皆在手 2022-09-13 22:30:16

不加入复选框呢? 查一下netwotk接口是否获取成功 还有一年返回数据是否符合bootstrap-table的填充规范

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文