当前位置 : 主页 > 网页制作 > Bootstarp >

Bootstrap分页查询

来源:互联网 收集:自由互联 发布时间:2021-06-12
前台方法: function show() { $( ‘#reportTable‘ ).bootstrapTable({ method: ‘get‘ , url: "@Url.Action("GetList", "UserInfoFun")" , pagination: true , // 分页 striped: false , pageSize: 10 , pageNumber: 1 , minimumCountColumns:

前台方法:

   function show() {
            $(‘#reportTable‘).bootstrapTable({
                method: ‘get‘,
                url: "@Url.Action("GetList", "UserInfoFun")",
                pagination: true,//分页
                striped: false,
                pageSize: 10,
                pageNumber: 1,
                minimumCountColumns: 1,
                queryParamsType: ‘count‘,
                sidePagination: ‘server‘,
                dataType: ‘json‘,
                contentType: ‘application/json‘,
                idField: ‘S_CASEID‘,
                queryParams: getQueryParams
            });
        }

 

 function getQueryParams(queryParams) {
            var options = $("#reportTable").bootstrapTable(‘getOptions‘);
            $.extend(options, queryParams);
            var sortOrder = options.sortOrder == "desc" ? " asc" : " desc";
            var sortName = options.sortName || "s_id";
            var temp = $("#fm_doc").serializeJsonObject();
            temp["pageIndex"] = (options.pageNumber - 1) * options.pageSize;
            temp["pageSize"] = options.pageSize;
            temp["sort"] = sortName + sortOrder;
           return temp;
        }

 

  function formatterOperation(value, row, index) {
            var str = "";
            str += "<a href=\"javascript:void(0)\" onclick=\"Edit(‘" + row["Id"] + "‘)\"><span class=‘glyphicon glyphicon-pencil‘></span>编辑</a>&nbsp;&nbsp;";
            str += "<a href=\"javascript:void(0)\" onclick=\"Delete(‘" + row["Id"] + "‘)\"><span class=‘glyphicon glyphicon-remove‘></span>删除</a>";
            return str;
        }
  function Delete(id) {
            if (confirm("确认要删除用户吗?")) {
                $.ajax({
                    url: "@Url.Action("Delete", "UserInfoFun")",
                    type: "post",
                    data: { id: id },
                    dataType: "json",
                    success: function (d) {
                        if (d.Success) {
                            alert("删除成功");
                            //doSearchByButton();
                        }
                        else {
                            alert(d.ErrorMsg);
                        }
                    }
                });
            }
        }
  function Edit(id) {
            TopLayerInfo(‘编辑用户‘, ‘@Url.Action("AddUser", "UserInfo")?IsAdd=false&id=‘ + id + ‘‘, ‘55%‘, ‘50%‘);
        }

 

前台Html:

 <div class="base-table" id="tabDiv" style="height:600px;margin-left:10px">
                <table id="reportTable" class="table baseTHead">
                    <thead>
                        <tr>
                            <th data-field="Id">用户帐号</th>
                            <th data-field="Name">姓名</th>
                            <th data-field="Policeinfo_Id">年龄</th>
                            <th data-formatter="formatterOperation" data-align="center" data-width="120px">操作</th>
                        </tr>
                    </thead>
                </table>
网友评论