温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

django +jQuery Grid Plugin 实现表格前提自动分页, 排序

发布时间:2020-07-09 11:06:14 来源:网络 阅读:2192 作者:yubochinese 栏目:web开发

由于django 中文在前台显示乱码,本文使用了 先在用django模板生成表格,再用jQuery Grid对表格 进行处理。

<link href="../pqgrid.min.css" rel="stylesheet">

<script type="text/javascript" src="../js/pqgrid.min.js"></script>

<script type="text/javascript" src="../js/pq-localize-zh.js"></script>


<div id="grid_table"></div> 用来显示jQuery Grid表格


<table border="1" cellspacing="0" cellpadding="0" class="fortune500" >

           <tbody>

<tr >

           <th>礼包ID</th>

<td >礼包名字</td>

<th >CDK剩余量</th>

           <th>礼包内容</th>

<td >生成日期</td>

         </tr>


       <tbody>

        {% for gift in gift_lists %} django生成的表格

        <tr>

<td >`gift`.`gift_id`</td>

<td >`gift`.`gift_name`</td>

<td >`gift`.`gift_nums`</td>

<td >`gift`.`gift_content`</td>

<td >`gift`.`gift_time`</td>

</tr>

{% endfor %}


           <!-- repeating rows end -->

       </tbody></table>

<script>

$(function () {

$("table.fortune500").css('min-height',(jQuery('#right').height()-200)+"px");

$("table.fortune500").css('min-width',jQuery('#right').width()+"px");

      var tbl = $("table.fortune500");

       var obj = $.paramquery.tableToArray(tbl);

       var newObj = {

width:jQuery('#right').width()+"px",

height:jQuery('#right').height()+"px",

title: "详细信息查询(刷新请按F5)",

flexHeight: true,

flexWidth: true,

bottomVisible : true , 显示表格底部,这样才能 显示出分页

freezeCols: 5, 不允许列进行 横向拖动,一共5列,所以设置为5

};

       newObj.dataModel = { data: obj.data, rPP: 25, paging: "local" }; 设置分页信息

       newObj.colModel = obj.colModel;

       $("#grid_table").pqGrid(newObj);

       tbl.css("display", "none");


});


</script>


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI