转载:jQuery flexigrid使用说明 (一、静态格式化表格)
转载地址:http://blog.csdn.net/guirudaoge/article/details/7044181
一、静态太格式化表格
flexigrid的静态格式化表格是通过调用 flexigrid();方法实现的
首先在body标签中编写表格及数据,然后通过调用flexigrid()可以把普通表格格式化为flexigrid表,当然还可以添加标题以及按钮。同过 $('.trSelected', grid)可以取得选择的行,它返回的是一个已经选择所有行的数组。
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <title> 静态flexigrid </title>
- <linkrel="stylesheet"type="text/css"href="./css/flexigrid.css">
- <scripttype="text/javascript"src="./js/jquery-1.6.2.min.js"></script>
- <scripttype="text/javascript"src="./js/flexigrid.js"></script>
- <script>
- $(document).ready(function(){
- $('.flexme1').flexigrid({
- buttons : [
- {name: '添加', bclass: 'add',onpress : test},
- {name: '删除', bclass: 'delete',onpress : test},
- {separator: true}
- ],
- title: '静态flexigrid',
- showTableToggleBtn: true,
- width: 750,
- height: 300
- });
- });
- function test(com, grid)
- {
- if (com == '删除')
- {
- confirm('Delete ' + $('.trSelected', grid).length + ' items?')
- }
- else if (com == '添加')
- {
- $("#addMsg").show(2000);
- alert('Add New Item');
- }
- }
- </script>
- </head>
- <body>
- <tableclass="flexme1">
- <thead>
- <tr>
- <thwidth="200">Col 1</th>
- <thwidth="150">Col 2</th>
- <thwidth="150">Col 3 is a long header name</th>
- <thwidth="200">Col 4</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>This is data 1 with overflowing content</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- <tr>
- <td>This is data 1</td>
- <td>This is data 2</td>
- <td>This is data 3</td>
- <td>This is data 4</td>
- </tr>
- </tbody>
- </table>
- </body>
- </html>