固定表头方法,导入框架在table里面填入数值,然后在js里面设置一定的高度

webUi
赵桐华 5 years ago
parent 69a5ded07a
commit 32e65ae918
  1. 7
      frontend/views/menu/index.php
  2. 7
      frontend/views/permissions/index.php

@ -21,7 +21,7 @@ use \common\libs\MyLib;
<div class="ibox-content"> <div class="ibox-content">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<table id="listTable" class="table" id="table" data-toggle="table" data-height="689"> <table id="listTable" class="table" id="table" data-toggle="table" data-height="708">
<thead class="bg-warning"> <thead class="bg-warning">
<tr> <tr>
<th data-field="show_id">ID</th> <th data-field="show_id">ID</th>
@ -107,6 +107,11 @@ use \common\libs\MyLib;
//table设置一定的高度 //table设置一定的高度
var tab=$("#listTable").attr('data-height'); var tab=$("#listTable").attr('data-height');
$('.fixed-table-body').css({'height':tab-40}); $('.fixed-table-body').css({'height':tab-40});
//当浏览器窗口变化时,表头与表格不对齐解决
$('#table').bootstrapTable();
$(window).resize(function () {
$('#table').bootstrapTable('resetView');
});
}); });
</script> </script>
<?php $this->endBlock(); ?> <?php $this->endBlock(); ?>

@ -21,7 +21,7 @@ use \common\libs\MyLib;
<div class="ibox-content"> <div class="ibox-content">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<table id="listTable" class="table" id="table" data-toggle="table" data-height="689"> <table id="listTable" class="table" id="table" data-toggle="table" data-height="708">
<thead class="bg-warning"> <thead class="bg-warning">
<tr> <tr>
<th data-field="id">ID</th> <th data-field="id">ID</th>
@ -103,6 +103,11 @@ use \common\libs\MyLib;
//table设置一定的高度 //table设置一定的高度
var tab=$("#listTable").attr('data-height'); var tab=$("#listTable").attr('data-height');
$('.fixed-table-body').css({'height':tab-40}); $('.fixed-table-body').css({'height':tab-40});
//当浏览器窗口变化时,表头与表格不对齐解决
$('#table').bootstrapTable();
$(window).resize(function () {
$('#table').bootstrapTable('resetView');
});
}); });
</script> </script>
<?php $this->endBlock(); ?> <?php $this->endBlock(); ?>

Loading…
Cancel
Save