使用说明
- 创建表格元素,例子如下:
<table id="table" class="table kungeekui-datagrid"
data-has-order="true"
data-height="500">
<thead>
<tr>
<th data-field="name" data-width="120">名称</th>
<th data-field="code" data-can-select="false">编号</th>
</tr>
</thead>
</table>
或者把配置合并到
data-options
属性:<table id="table" class="table kungeekui-datagrid" data-options="hasOrder:true,height:500"> <thead> <tr> <th data-options="field:'name',width:120">名称</th> <th data-options="field:'gdbh',canSelect:false">编号</th> </tr> </thead> </table>
data-options
属性识别类似json格式的字符串,区别就是头尾没有大括号,变量名不加引号。
- 通过jquery扩展方法初始化插件:
$('#table').datagrid();
通过js初始化插件:
var myDatagrid = new Datagrid({ target:$('#table'), heigth:500 //...other options });
Datagrid会在页面window.onload事件内自动初始化样式含有
.kungeekui-datagrid
类的表格;