鍍金池/ 問答/HTML/ 使用bootstrap table時(shí)不能顯示篩選列和分頁(yè)每頁(yè)顯示的行數(shù)?

使用bootstrap table時(shí)不能顯示篩選列和分頁(yè)每頁(yè)顯示的行數(shù)?

在學(xué)習(xí)bootstrap-table時(shí)遇到不能顯示列篩選和分頁(yè)每頁(yè)顯示行數(shù),點(diǎn)擊的時(shí)候完全沒反應(yīng)。有沒有大神能幫忙解答一下?
圖片描述

圖片描述

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    var clients = [];
    $(function () {
        clients = clientsInit();
        //1.初始化Table
        var oTable = new TableInit();
        oTable.Init();
    })
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增用戶",
            url: "/SystemManage/User/Form",
            width: "700px",
            height: "510px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function clientsInit() {
        var dataJson = {
            dataItems: [],
            organize: [],
            role: [],
            duty: [],
            user: [],
            authorizeMenu: [],
            authorizeButton: []
        };
        var init = function () {
            $.ajax({
                url: "/ClientsData/GetClientsDataJson",
                type: "get",
                dataType: "json",
                async: false,
                success: function (data) {
                    dataJson.dataItems = data.dataItems;
                    dataJson.organize = data.organize;
                    dataJson.role = data.role;
                    dataJson.duty = data.duty;
                    dataJson.authorizeMenu = eval(data.authorizeMenu);
                    dataJson.authorizeButton = data.authorizeButton;
                }
            });
        }
        init();
        return dataJson;
    }
    var TableInit = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function () {
            $('#gridList').bootstrapTable({
                url: '/SystemManage/User/GetGridJson',         //請(qǐng)求后臺(tái)的URL(*)
                method: 'get',                      //請(qǐng)求方式(*)
                toolbar: '#toolbar',                //工具按鈕用哪個(gè)容器
                striped: true,                      //是否顯示行間隔色
                cache: false,                       //是否使用緩存,默認(rèn)為true,所以一般情況下需要設(shè)置一下這個(gè)屬性(*)
                pagination: true,                   //是否顯示分頁(yè)(*)
                sortable: false,                     //是否啟用排序
                sortOrder: "asc",                   //排序方式
                queryParams: oTableInit.queryParams,//傳遞參數(shù)(*)
                sidePagination: "server",           //分頁(yè)方式:client客戶端分頁(yè),server服務(wù)端分頁(yè)(*)
                pageNumber: 1,                       //初始化加載第一頁(yè),默認(rèn)第一頁(yè)
                pageSize: 25,                       //每頁(yè)的記錄行數(shù)(*)
                pageList: [10, 25, 50, 100],        //可供選擇的每頁(yè)的行數(shù)(*)
                search: true,                       //是否顯示表格搜索,此搜索是客戶端搜索,不會(huì)進(jìn)服務(wù)端,所以,個(gè)人感覺意義不大
                strictSearch: true,
                showColumns: true,                  //是否顯示所有的列
                showRefresh: true,                  //是否顯示刷新按鈕
                minimumCountColumns: 2,             //最少允許的列數(shù)
                clickToSelect: true,                //是否啟用點(diǎn)擊選中行
                height: $(window).height() - 40,                        //行高,如果沒有設(shè)置height屬性,表格自動(dòng)根據(jù)記錄條數(shù)覺得表格高度
                //uniqueId: "ID",                     //每一行的唯一標(biāo)識(shí),一般為主鍵列
                showToggle: true,                    //是否顯示詳細(xì)視圖和列表視圖的切換按鈕
                cardView: false,                    //是否顯示詳細(xì)視圖
                detailView: false,                   //是否顯示父子表
                queryParamsType : "undefined",
                columns: [{
                    checkbox: true
                }, {
                    field: 'F_Id',
                    title: '主鍵'
                }, {
                    field: 'F_Account',
                    title: '賬戶'
                }, {
                    field: 'F_RealName',
                    title: '姓名'
                }, {
                    field: 'F_Gender',
                    title: '性別',
                    formatter: function (value, row, index) {
                        if (value == '1') {
                            return '男';
                        } else {
                            return '女';
                        }
                    }
                }, {
                    field: 'F_MobilePhone',
                    title: '手機(jī)',
                }, {
                    field: 'F_OrganizeId',
                    title: '公司',
                    formatter: function (cellvalue, options, rowObject) {
                    return top.clients.organize[cellvalue] == null ? "" : top.clients.organize[cellvalue].fullname;
                    }
                }, {
                    field: 'F_DepartmentId',
                    title: '部門',
                    formatter: function (cellvalue, options, rowObject) {
                        return top.clients.organize[cellvalue] == null ? "" : top.clients.organize[cellvalue].fullname;
                    }
                }, {
                    field: 'F_DutyId',
                    title: '崗位',
                    formatter: function (cellvalue, options, rowObject) {
                        return top.clients.duty[cellvalue] == null ? "" : top.clients.duty[cellvalue].fullname;
                    }
                }, {
                    field: 'F_CreatorTime',
                    title: '創(chuàng)建時(shí)間',
                }, {
                    field: 'F_EnabledMark',
                    title: '允許登錄',
                }, {
                    field: 'F_Description',
                    title: '備注',
                }, ]
            });
        };

        //得到查詢的參數(shù)
        oTableInit.queryParams = function (params) {
            var temp = {   //這里的鍵的名字和控制器的變量名必須一直,這邊改動(dòng),控制器也需要改成一樣的
                pagesize: params.pageSize,   //頁(yè)面大小
                page: params.pageNumber,  //頁(yè)碼
                sord:params.sortOrder,
                sidx: 'F_DepartmentId asc,F_CreatorTime desc'  //排序列
                //departmentname: $("#txt_search_departmentname").val(),
                //statu: $("#txt_search_statu").val()
            };
            return temp;
        };
        return oTableInit;
    };
</script>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="topPanel">
        <div id="toolbar">
            <button id="btn_add" type="button" class="btn btn-white"  data-toggle="modal" data-target="#myModal" onclick="btn_add()">
                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
            </button>
        </div>
    </div>
    <div class="gridPanel">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</div>
<!-- 全局js -->
<script src="~/Content/hplus/js/jquery.min.js?v=2.1.4"></script>
<script src="~/Content/hplus/js/bootstrap.min.js?v=3.3.6"></script>
<script src="~/Content/js/framework-ui.js"></script>
<!-- 自定義js -->
<script type="text/javascript" src="~/Content/hplus/js/contabs.js"></script>
<script src="~/Content/hplus/js/content.js?v=1.0.0"></script>
<!-- Bootstrap table -->
<script src="~/Content/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="~/Content/hplus/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="~/Content/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<!-- Peity -->
<script src="~/Content/hplus/js/demo/bootstrap-table-demo.js"></script>
回答
編輯回答
懶豬

bootstrap down下拉框依賴bootstrap.js文件,添加即可,需要注意的是bootstrap.css和bootstrap.js的版本需一致且不要低于3.3.5的版本,還有一個(gè)地方要注意,bootstrap-table及bootstrap 3.3.5依賴jquery的版本不要低于1.9.1,按照上述說法去做不會(huì)有問題的

2018年5月17日 10:14
編輯回答
久不遇

pageList: [10, 25, 50, 100],
smartDisplay:false,
添加這個(gè)配置項(xiàng)就好了

2017年7月11日 07:21
編輯回答
糖豆豆

我也遇到了這個(gè)問題。
我出問題的原因是引入多個(gè)bootstrap.js文件。
我解決的方法是只引入一次。把多余的去掉。

2017年12月12日 13:11
編輯回答
夏木

我也遇到了這個(gè)問題,我是將bootstrap.js刪除了才解決的。我懷疑與剩下的某個(gè)文件有沖突,(重點(diǎn)懷疑bootstrap-table.js)才造成了問題,
附上正常時(shí)引用的文件名
<script type="text/javascript" src="${ctx}/static/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/popper.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/bootbox.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/bootstrap-table.js"></script>
<script type="text/javascript" src="${ctx}/static/js/common.js"></script>
<script type="text/javascript"src="${ctx}/static/js/bootstrap-table-zh-CN.min.js"></script>

2018年8月27日 15:52
編輯回答
撿肥皂

我最近也遇到了這個(gè)問題,不知你是否解決,網(wǎng)上查詢之后得知是bootstrap.js的問題,查看引用路徑是否正確,還有你是否修改過,用官網(wǎng)上的替換一下試試。我這樣做之后是解決的。

2017年1月5日 06:48
編輯回答
悶油瓶

樓主好,我也剛學(xué)Bootstrap,也遇到了這個(gè)問題,怎么解決的呢

2018年1月27日 20:24