bootstrap 分页详解

1.导入js,css样式文件,缺一不可,顺序不可乱

    <link rel="stylesheet" href="css/qunit-1.11.0.css">
     <link rel="stylesheet" href="css/bootstrapv3.css">
  	 
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
	
    <script src="js/bootstrap-paginator.js"></script>
    <script src="js/qunit-1.11.0.js"></script>

2.代码,options绝大数可选配置
	<body>
		<div id="alert-content"></div>
		<div id="alert-content"></div>
	<div>
    <ul id='bp-3-element-test'></ul>
</div>
<script>
	     $(function(){
 

            var element = $('#bp-3-element-test');

            var options = {
                bootstrapMajorVersion:3,
                currentPage: 3,//当前页
                numberOfPages: 5,//每次展示多少页
                totalPages:11,//总页数
				size:'small',//大小
				alignment:'right',//位置
				pageUrl: function(type, page, current){//访问连接
	               		 return "#"+page;
	            	},
	            itemTexts: function (type, page, current) { //样式文字设置
                    switch (type) {
                    case "first":
                        return "首页";
                    case "prev":
                        return "前一页";
                    case "next":
                        return "下一页";
                    case "last":
                        return "最后";
                    case "page":
                        return ""+page;
                    }
                },
                shouldShowPage:function(type, page, current){//控制哪些显示,哪些隐藏
		                switch(type)
		                {
		                    case "first":
		                    case "last":
		                        return false;  //首页最后一页隐藏
		                    default:
		                        return true;  //其他显示
		                }
           		 },
           		 tooltipTitles: function (type, page, current) { //提示框,当鼠标放上去给提示
	                    switch (type) {
	                    case "first":
	                        return "提示首页";
	                    case "prev":
	                        return "提示前页";
	                    case "next":
	                        return "Tooltip for next page";
	                    case "last":
	                        return "Tooltip for last page";
	                 
	                    }
	                },
	            useBootstrapTooltip:true,
	            
	            onPageClicked: function(e,originalEvent,type,page){
                $('#alert-content').text("点击页数时,触发该函数, type: "+type+" page: "+page);
            	},
            	
            	onPageChanged: function(e,oldPage,newPage){
                $('#alert-content').text("当页面改变时,触发该函数, old: "+oldPage+" new: "+newPage);
            }
           		 
            
            }
				 
            

            element.bootstrapPaginator(options);

         
        
    });
	
</script>



	</body>
</html>

效果图



3.官方文档下载地址,包含英文文档,和所有文件

https://github.com/lyonlai/bootstrap-paginator



  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Bootstrap Table中,搜索是一个非常常用的功能。它可以帮助用户快速找到他们所需要的数据,提高用户体验。下面我们来详细介绍Bootstrap Table搜索功能的使用方法。 1. 初始化表格 首先需要在HTML代码中添加Bootstrap Table表格的结构,并在JavaScript代码中初始化表格。初始化表格的代码可以参考以下示例: ``` <table id="table" data-url="data.json" data-search="true"> <thead> <tr> <th data-field="id">ID</th> <th data-field="name">Name</th> <th data-field="price">Price</th> </tr> </thead> </table> <script> $(function() { $('#table').bootstrapTable({ // 表格配置 }); }); </script> ``` 在上面的代码中,我们通过data-search="true"来开启表格的搜索功能。 2. 使用搜索框 Bootstrap Table提供了一个默认的搜索框,可以直接使用。只需要在表格的配置中设置search: true即可。示例代码如下: ``` <table id="table" data-url="data.json" data-search="true"> <thead> <tr> <th data-field="id">ID</th> <th data-field="name">Name</th> <th data-field="price">Price</th> </tr> </thead> </table> <script> $(function() { $('#table').bootstrapTable({ search: true, // 表格配置 }); }); </script> ``` 在上面的代码中,我们将search设置为true,表格就会自动添加一个搜索框。 3. 自定义搜索框 如果想要自定义搜索框,可以在HTML代码中手动添加一个搜索框,并在JavaScript中绑定搜索事件。示例代码如下: ``` <div class="input-group"> <input type="text" class="form-control" id="searchInput" placeholder="Search..."> <span class="input-group-btn"> <button class="btn btn-default" type="button" id="searchButton"> <span class="glyphicon glyphicon-search"></span> </button> </span> </div> <table id="table" data-url="data.json"> <thead> <tr> <th data-field="id">ID</th> <th data-field="name">Name</th> <th data-field="price">Price</th> </tr> </thead> </table> <script> $(function() { $('#table').bootstrapTable({ // 表格配置 }); $('#searchButton').click(function() { var searchText = $('#searchInput').val(); $('#table').bootstrapTable('search', searchText); }); }); </script> ``` 在上面的代码中,我们手动添加了一个搜索框,并在JavaScript中绑定了搜索按钮的点击事件。当用户点击搜索按钮时,会获取搜索框的内容并使用Bootstrap Table提供的search方法来搜索匹配的数据。 以上就是Bootstrap Table搜索功能的详细介绍。你可以根据自己的需求来选择使用默认搜索框还是自定义搜索框。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值