EasyUI 之datagrid 使用 【DataGrid属性解释】

本文详细解析了DataGrid属性与DatagridColumns配置的使用方法,包括标题、图标、边框、宽度、高度、列配置及事件处理等核心内容。了解如何通过属性配置实现高效的数据展示与交互。

可选的参数

DataGrid 属性

覆写了 $.fn.datagrid.defaults.

 

参数名类型描述默认值
titlestringDatagrid面板的标题null
iconClsstring在面板上通过一个CSS类显示16x16图标。null
borderboolean设置面板是否具有边框TRUE
widthnumberdatagrid面板的宽度auto
heightnumberdatagrid面板的高度auto
columnsarrayDataGrid列配置对象null
frozenColumnsarray冻结的列,被现实在左边null
stripedboolean设置是否让单元格显示条纹。默认false。FALSE
methodstring通过该方法类型请求远程数据。默认post。post
nowrapboolean是否包裹数据,默认为包裹数据显示在一行TRUE
idFieldstring标识字段,或者说主键字段null
urlstring请求数据的URL.null
loadMsgstring加载数据时显示的信息Processing, please wait …
paginationboolean是否显示分页工具栏FALSE
rownumbersboolean  

 


DataGrid Columns 是一个数组对象, 数组里的对象也是一个数组,数组里的每一个小对象就是一个列字段,例如:
Column 属性

columns:[[
{field:'itemid',title:'Item ID',rowspan:2,width:80,sortable:true},
{field:'productid',title:'Product ID',rowspan:2,width:80,sortable:true},
{title:'Item Details',colspan:4}
],[
{field:'listprice',title:'List Price',width:80,align:'right',sortable:true},
{field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},
{field:'attr1',title:'Attribute',width:100},
{field:'status',title:'Status',width:60}
]]
名称类型描述默认值
titlestring列字段要现实的名称undefined
fieldstring列字段undefined
widthnumber宽度undefined
rowspannumber单元格行数undefined
colspannumber单元格列数undefined
alignstring文本对齐方式,同align属性.undefined
sortableboolean是否可以被排序.undefined
checkboxboolean是否具有多选框undefined

Events(事件)

NameParametersDescription
onLoadSuccessnone调用远程数据成功是激活
onLoadErrornone装载错误时激活
onClickRowrowIndex, rowData点击一行时激活,参数包括:
rowIndex:点击的行数,从0开始
rowData: 当前行的数据
onDblClickRowrowIndex, rowData双击一行是触发,参数包括:
rowIndex:点击的行数,从0开始
rowData: 当前行的数据
onSortColumnsort, order对一列进行排序时激活,参数包括:
sort:排序字段名称
order: 排序规则,升序,降序
onSelectrowIndex, rowData选中一行时激活,参数有:
rowIndex:选中的行数
rowData: 数据
onUnselectrowIndex, rowData取消选中时激活,参数:
rowIndex:选中的行数
rowData: 数据

Methods(方法)

 

NameParameterDescription
optionsnone返回所有属性
resizenone重置大小布局
reloadnone重新加载数据
fixColumnSizenone调整列的大小
loadDataparam装载数据,以前的数据会被移除
getSelectednone返回选中的行,没有则返回空
getSelectionsnone返回所有的行,空则返回空数组
clearSelectionsnone取消所有选中
selectRowindex选中一行,参数为行号
selectRecordidValue根据主键查询出一条记录
unselectRowindex取消选中一行

转载于:https://www.cnblogs.com/sandyliu1999/p/4973663.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值