標籤:django +jquery grid plugin 實現表格前提自動分頁 排序
由於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" style="margin:auto;" >
<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>
本文出自 “python django jqurey” 部落格,請務必保留此出處http://tomyu.blog.51cto.com/705648/1408779