Django +jquery grid Plugin Implement table Prerequisites automatic paging, sorting

Source: Internet
Author: User

Since Django Chinese is garbled in the foreground, this article uses the Django template to generate the table, and then uses the jquery grid to process the table.

<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> for displaying jquery grid tables


<table border= "1" cellspacing= "0" cellpadding= "0" class= "fortune500" style= "Margin:auto;" >

<tbody>

<tr >

<th> Gift Pack Id</th>

<TD > Gift Package name </td>

<th >CDK remaining Volume </th>

<th> Package Content </th>

<TD > Build Date </td>

</tr>


<tbody>

{% for gift in gift_lists%} Django-Generated tables

<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: "More information query (refresh please press F5)",

Flexheight:true,

Flexwidth:true,

Bottomvisible:true, display the bottom of the table so that the pagination can be displayed

Freezecols:5, the column is not allowed to drag horizontally, altogether 5 columns, so set to 5

};

Newobj.datamodel = {Data:obj.data, rpp:25, paging: "Local"}; Set Paging information

Newobj.colmodel = Obj.colmodel;

$ ("#grid_table"). Pqgrid (NEWOBJ);

TBL.CSS ("Display", "none");


});


</script>


This article is from the "Python Django Jqurey" blog, so be sure to keep this source http://tomyu.blog.51cto.com/705648/1408779

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.