django +jQuery Grid Plugin 實現表格前提自動分頁, 排序

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.