欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

jQuery表格插件ParamQuery简单使用方法示例

程序员文章站 2022-07-25 19:48:42
jquery表格插件paramquery简单使用方法示例。 实现步骤: 先在html的head中加入对jquery和jquery ui的引用:   . 代码如...

jquery表格插件paramquery简单使用方法示例。

jQuery表格插件ParamQuery简单使用方法示例

实现步骤:
先在html的head中加入对jquery和jquery ui的引用:

 

. 代码如下:


<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>       <!--用了cdn链接(自适应http, https的切换),所以src的开头直接用了"//"-->
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>  <!--同上-->

 


再加入对param query grid的引用:

. 代码如下:


<link rel="stylesheet" href="/content/pqgrid/pqgrid.min.css" />           <!--这个css文件必须引用,无论你是用了皮肤,还是没有用到皮肤,都要引用-->
<script type="text/javascript" src="/scripts/pqgrid.min.js" ></script>    <!--这个js文件必须引用-->

 

增加脚本代码:

. 代码如下:


$(function () {
                var data = [    [1, 'exxon mobil', '339,938.0', '36,130.0'],
                                [2, 'wal-mart stores', '315,654.0', '11,231.0'],
                                [3, 'royal dutch shell', '306,731.0', '25,311.0'],
                                [4, 'bp', '267,600.0', '22,341.0'],
                                [5, 'general motors', '192,604.0', '-10,567.0'],
                                [6, 'chevron', '189,481.0', '14,099.0'],
                                [7, 'daimlerchrysler', '186,106.3', '3,536.3'],
                                [8, 'toyota motor', '185,805.0', '12,119.6'],
                                [9, 'ford motor', '177,210.0', '2,024.0'],
                                [10, 'conocophillips', '166,683.0', '13,529.0'],
                                [11, 'general electric', '157,153.0', '16,353.0'],
                                [12, 'total', '152,360.7', '15,250.0'],
                                [13, 'ing group', '138,235.3', '8,958.9'],
                                [14, 'citigroup', '131,045.0', '24,589.0'],
                                [15, 'axa', '129,839.2', '5,186.5'],
                                [16, 'allianz', '121,406.0', '5,442.4'],
                                [17, 'volkswagen', '118,376.6', '1,391.7'],
                                [18, 'fortis', '112,351.4', '4,896.3'],
                                [19, 'crédit agricole', '110,764.6', '7,434.3'],
                                [20, 'american intl. group', '108,905.0', '10,477.0']
                            ];

 

                var obj = {};
                obj.width = 700;
                obj.height = 400;
                obj.colmodel = [{ title: "rank", width: 100, datatype: "integer" },
                    { title: "company", width: 200, datatype: "string" },
                    { title: "revenues ($ millions)", width: 150, datatype: "float", align: "right" },
                    { title: "profits ($ millions)", width: 150, datatype: "float", align: "right" }];
                obj.datamodel = { data: data };
                $("#grid_array").pqgrid(obj);

            });

 

最后,在要显示的地方加入p元素,用来显示表格:

 

. 代码如下:


<p id="grid_array"></p>

 

运行就能看到效果

加入theme皮肤的demo

jQuery表格插件ParamQuery简单使用方法示例

实现步骤:
js代码逻辑部分没有任何变动,哈哈。
html的head部分增加那么一句style引用,就搞定了,如下:

 

. 代码如下:


<link rel="stylesheet" href="/content/pqgrid/pqgrid.min.css" />               <!- 这句就是增加的,其他没有任何变动...哈哈 ->
<link rel="stylesheet" href="/content/pqgrid/themes/peach/pq-grid.css" />
<script type="text/javascript" src="/scripts/pqgrid.min.js" ></script>