API
Component

Grid ($UI/system/components/justep/grid/grid)

使用范围:UI2

Contents

component Grid ($UI/system/components/justep/grid/grid) extends ViewComponent

<b>使用场景</b>:展示网格或树形数据,可以分页显示数据; <b>使用方法</b>:在页面上添加grid组件,绑定显示的data数据,可以设置分组,设置多列头; ## <b>文档链接</b>:#http://docs.newdao.net/zhuo-mian-nei-rong-zu-jian/fu-za-biao-ge.html#

Constructor Top

  Grid ()
  Grid ( options)

Constants Top

const string virtualRootID

虚根行ID

Attributes Top

string altclass

自定义交替行样式class

boolean altRows

使用交替行样式,默认值:false

string appearance

显示样式,取值范围:grid、treeGrid、tree,默认值:grid

string caption

标题

boolean cascade

树形多选级联选择,默认值:false

string checkedclass

多选checked的class

string class

组件class

string data

关联的data组件xid

boolean directEdit

直接进入编辑,否则双击进入编辑,默认值:true

string expandColumn

树形的展开列

string filter

数据过滤表达式,表达式中可以使用$model,$object,$parent,$row(执行过滤的数据行对象)变量

integer frozenColumnCount

冻结列数

integer height

高度,当使用auto时自动根据内容进行展现,当使用100%时自动使用父容器高度

boolean hiddenCaptionbar

隐藏标题栏,默认值:false

boolean multiboxonly

仅使用checkBox多选,默认值:false

boolean multiselect

使用checkBox多选,默认值:false

integer multiselectWidth

多选列宽,默认值:20

string rowAttr

增加在行上属性的表达式,表达式执行结果返回Object,可以包含style、class属性,也可以增加自定义属性 表达式中可以使用$model,$row(当前渲染的数据行对象)变量 如: 1、简单 {style:'height:80px;',class:'...'} 2、根据数据设置不同底色 $row.val('fString')=='北京'?{style:'background:red;'}:{style:'background:blue;'} <b>注:</b> 修改值时不会刺激执行

integer rowNumberWidth

行号列宽,默认值:20

boolean serverSort

服务端排序,默认值:true

boolean showRowNumber

显示行号,默认值:false

boolean useFilterBar

使用过滤条,默认值:false

boolean useFooter

使用footer,默认值:false,打开后可以通过api:setFooterData设置footer显示内容

boolean useVirtualRoot

树形展现使用虚根,默认值:false

string virtualRootLabel

树形展现虚根名称

integer width

宽度,当使用auto时自动根据内容进行展现,当使用100%时自动使用父容器宽度

string xid

组件标示

Static Methods Top

boolean isVirtualRoot (string rowID)

Methods Top

void addRow (Row row)
void collapseAll ()
void collapseRow (string rowID)
void deleteCheckedRows ()
void deleteRow (string rowID)
void editCell (TD cell)
void editStop ()
void expandAll ()
void expandByIDPath (string path)
void expandLevel (int level)
void expandRow (string rowID)
td getCell (string rowID, string col)
integer getCellIndex (Dom td)
list<Row> getCheckedRows ()
list getCheckeds ()
object getColDef (integer colIndex)
integer getColIndex (string colName)
string getColName (integer colIndex)
integer getColWidth (string col)
Data getData ()
Row getDataRow (node node)
string getFilter ()
integer getFooterHeight ()
object getGridParam (string name)
integer getHeaderHeight ()
integer getHeight ()
void getNextCell (TD cell)
TR getRowByID (string rowID)
string getSelection ()
integer getWidth ()
void groupBy (string col)
void groupByRemove (string col)
void hideCol (string col)
boolean isChecked (string rowID)
boolean isExpanded (string rowID)
boolean isGrouping ()
boolean isMultiSelect ()
boolean isTree ()
boolean isTreeGrid ()
void nextEditCell (TD cell)
void refresh ()
void selectVirtualRoot ()
void setCaption (string caption)
void setCell (string rowID, string col, object css, object attr)
void setColWidth (string col, integer width)
void setFilter (string filter)
void setFooterData (object footerData)
void setGridParam (object params)
void setHeadCheckBox (boolean checked)
void setHeight (integer height)
void setLabel (string colName, string label, string | object css, object attr)
void setRowChecked (string rowID, boolean checked)
void setRowCss (string rowID, object css)
void setSelection (string rowID)
void setWidth (integer width)
void showCol (string col)

Operations Top

deleteCheckedRows ()
setCols ()

Events Top

void onBeforeInit (BeforeInitEvent event)
void onBeforeRowSelect (BeforeRowSelectEvent event)
void onCellRender (CellRenderEvent event)
void onCollapseRow (CollapseRowEvent event)
void onExpandRow (ExpandRowEvent event)
void onGroupTextRender (GroupTextRenderEvent event)
void onIndexChanged (IndexChangedEvent event)
void onInit (ViewEvent event)
void onLastEditorPressEnter (LastEditorPressEnterEvent event)
void onReload (ViewEvent event)
void onRowCheck (RowCheckEvent event)
void onRowChecked (RowCheckedEvent event)
void onRowCheckedAll (RowCheckedAllEvent event)
void onRowClick (RowClickEvent event)
void onRowDblClick (RowClickEvent event)
void onRowSelect (RowSelectEvent event)
void onTreeIconRender (TreeIconRenderEvent event)

Constructor details Top

public Grid ()

<b>使用场景</b>:展示网格或树形数据,可以分页显示数据; <b>使用方法</b>:在页面上添加grid组件,绑定显示的data数据,可以设置分组,设置多列头; ## <b>文档链接</b>:#http://docs.newdao.net/zhuo-mian-nei-rong-zu-jian/fu-za-biao-ge.html#

public Grid ( options)

构造函数

Inherited from ViewComponent

	
		参数options格式类似{parent:xx, config:{}},parent是组件的父节点,允许为空或不指定,config是组件的参数选项
	 

Parameters

options

参数选项

Constants Detail Top

static public string virtualRootID

虚根行ID

Static Methods Detail Top

static public boolean isVirtualRoot (string rowID)

判断是否虚根

Parameters

string rowID

行ID

Return Value

boolean

Attributes Detail Top

public string altclass

自定义交替行样式class

public boolean altRows

使用交替行样式,默认值:false

public string appearance

显示样式,取值范围:grid、treeGrid、tree,默认值:grid

public string caption

标题

public boolean cascade

树形多选级联选择,默认值:false

public string checkedclass

多选checked的class

public string class

组件class

	
		扩展样式: x-grid-no-bordered
		列头对齐方式: x-grid-title-center,x-grid-title-left,x-grid-title-right,x-grid-title-justify
	

public string data

关联的data组件xid

public boolean directEdit

直接进入编辑,否则双击进入编辑,默认值:true

public string expandColumn

树形的展开列

public string filter

数据过滤表达式,表达式中可以使用$model,$object,$parent,$row(执行过滤的数据行对象)变量

public integer frozenColumnCount

冻结列数

public integer height

高度,当使用auto时自动根据内容进行展现,当使用100%时自动使用父容器高度

public boolean hiddenCaptionbar

隐藏标题栏,默认值:false

public boolean multiboxonly

仅使用checkBox多选,默认值:false

public boolean multiselect

使用checkBox多选,默认值:false

public integer multiselectWidth

多选列宽,默认值:20

public string rowAttr

增加在行上属性的表达式,表达式执行结果返回Object,可以包含style、class属性,也可以增加自定义属性 表达式中可以使用$model,$row(当前渲染的数据行对象)变量 如: 1、简单 {style:'height:80px;',class:'...'} 2、根据数据设置不同底色 $row.val('fString')=='北京'?{style:'background:red;'}:{style:'background:blue;'} <b>注:</b> 修改值时不会刺激执行

public integer rowNumberWidth

行号列宽,默认值:20

public boolean serverSort

服务端排序,默认值:true

public boolean showRowNumber

显示行号,默认值:false

public boolean useFilterBar

使用过滤条,默认值:false

public boolean useFooter

使用footer,默认值:false,打开后可以通过api:setFooterData设置footer显示内容

public boolean useVirtualRoot

树形展现使用虚根,默认值:false

public string virtualRootLabel

树形展现虚根名称

public integer width

宽度,当使用auto时自动根据内容进行展现,当使用100%时自动使用父容器宽度

public string xid

组件标示

Methods Detail Top

public void addRow (Row row)

增加行

Parameters

Row row

data的行对象

Return Value

void

public void collapseAll ()

所有行折叠

Return Value

void

public void collapseRow (string rowID)

行折叠

Parameters

string rowID

行ID

Return Value

void

public void deleteCheckedRows ()

多选时删除勾选行

Return Value

void

public void deleteRow (string rowID)

删除行

Parameters

string rowID

行ID

Return Value

void

public void editCell (TD cell)

单元格进入编辑状态,受列上定义的editable属性和data的readonly规则影响

Parameters

TD cell

单元格

Return Value

void

public void editStop ()

单元格结束编辑

Return Value

void

public void expandAll ()

所有行展开,注意:当数据较多时有可能引发性能问题,慎重使用

Return Value

void

public void expandByIDPath (string path)

根据ID路径行展开

Parameters

string path

ID路径

Return Value

void

public void expandLevel (int level)

展开到第level层,注意:当数据较多时有可能引发性能问题,慎重使用

Parameters

int level

展开层数

Return Value

void

public void expandRow (string rowID)

行展开

Parameters

string rowID

行ID

Return Value

void

public td getCell (string rowID, string col)

获取cell

Parameters

string rowID

行ID

string col

Return Value

td

获取到的cell TD

public integer getCellIndex (Dom td)

获取列索引

Parameters

Dom td

td节点

Return Value

integer

列索引

public list<Row> getCheckedRows ()

返回多选选中的行

Return Value

list<Row>

rows 行数组

public list getCheckeds ()

返回多选选中的行ID

Return Value

list

rowIDs 行ID数组

public object getColDef (integer colIndex)

获取列定义

Parameters

integer colIndex

列索引

Return Value

object

列定义

public integer getColIndex (string colName)

获取列索引

Parameters

string colName

列名

Return Value

integer

列索引

public string getColName (integer colIndex)

获取列名

Parameters

integer colIndex

列索引

Return Value

string

列名

public integer getColWidth (string col)

获取列宽

Parameters

string col

Return Value

integer

列宽

public Data getData ()

获取grid绑定的data对象

Return Value

Data

public Row getDataRow (node node)

根据行html节点获取bind的Data行对象

Parameters

node node

html节点

Return Value

Row

返回Data的行对象

public string getFilter ()

获取DataTables绑定的data filter表达式

Return Value

string

public integer getFooterHeight ()

获取脚高

Return Value

integer

脚高

public object getGridParam (string name)

获取参数值

Parameters

string name

参数名称

Return Value

object

参数值

public integer getHeaderHeight ()

获取头高

Return Value

integer

头高

public integer getHeight ()

获取grid高

Return Value

integer

grid高

public void getNextCell (TD cell)

获取下一个单元格,没有时返回null

Parameters

TD cell

单元格

Return Value

void

public TR getRowByID (string rowID)

根据行ID获取TR

Parameters

string rowID

行ID

Return Value

TR

返回TR

public string getSelection ()

返回选中行的ID

Return Value

string

选中行ID

public integer getWidth ()

获取grid宽

Return Value

integer

grid宽

public void groupBy (string col)

指定分组

Parameters

string col

列名

Return Value

void

public void groupByRemove (string col)

去除分组

Parameters

string col

列名

Return Value

void

public void hideCol (string col)

隐藏grid列

Parameters

string col

列名

Return Value

void

public boolean isChecked (string rowID)

多选是否选中行

Parameters

string rowID

行ID

Return Value

boolean

是否选中

public boolean isExpanded (string rowID)

判断行是否展开

Parameters

string rowID

行ID

Return Value

boolean

是否展开

public boolean isGrouping ()

是否使用分组

Return Value

boolean

是否使用分组

public boolean isMultiSelect ()

是否多选

Return Value

boolean

public boolean isTree ()

是否tree

Return Value

boolean

是否tree

public boolean isTreeGrid ()

是否treeGrid,当tree时也返回true

Return Value

boolean

是否treeGrid

public void nextEditCell (TD cell)

下一个可以编辑的单元格进入编辑状态

Parameters

TD cell

单元格

Return Value

void

public void refresh ()

重新刷新grid

Return Value

void

public void selectVirtualRoot ()

选中虚根

Return Value

void

public void setCaption (string caption)

设置标题

Parameters

string caption

标题

Return Value

void

public void setCell (string rowID, string col, object css, object attr)

设置单元格样式或者属性

Parameters

string rowID

行ID

string col

object css

样式

object attr

属性

Return Value

void

public void setColWidth (string col, integer width)

设置单元格

Parameters

string col

integer width

列宽

Return Value

void

public void setFilter (string filter)

设置data filter表达式

Parameters

string filter

filter表达式

Return Value

void

public void setFooterData (object footerData)

设置footer数据

Parameters

object footerData

footer数据,格式为:{列名:数据,...},如:{sName:'合计:',sInt:500}

Return Value

void

public void setGridParam (object params)

设置参数值

Parameters

object params

参数,json格式

Return Value

void

public void setHeadCheckBox (boolean checked)

多选时设置列头多选checkbox状态

Parameters

boolean checked

选中状态

Return Value

void

public void setHeight (integer height)

设置grid高

Parameters

integer height

Return Value

void

public void setLabel (string colName, string label, string | object css, object attr)

设置列显示名,当多表头时此函数无效

Parameters

string colName

列名

string label

显示名,支持html

string | object css

列头样式,当类型是string时按class处理,当object时按style处理(格式如:{color: 'red'})

object attr

列上增加的属性,如:增加属性_name,{_name:'...'}

Return Value

void

public void setRowChecked (string rowID, boolean checked)

设置行多选状态

Parameters

string rowID

行ID

boolean checked

选中状态

Return Value

void

public void setRowCss (string rowID, object css)

设置行的css

Parameters

string rowID

行ID

object css

样式,同jquery格式,如:{height:100,width:50,...}

Return Value

void

public void setSelection (string rowID)

设置选中行

Parameters

string rowID

行ID

Return Value

void

public void setWidth (integer width)

设置grid宽

Parameters

integer width

Return Value

void

public void showCol (string col)

显示grid列

Parameters

string col

列名

Return Value

void

Operations Detail Top

public deleteCheckedRows ()

多选时删除勾选行

public setCols ()

调整列

Events Detail Top

public void onBeforeInit (BeforeInitEvent event)

[回调型事件]创建grid组件前事件

Parameters

BeforeInitEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "settings" : 创建grid的参数 }

Return Value

void

public void onBeforeRowSelect (BeforeRowSelectEvent event)

[回调型事件]选中行前,通过cancel可控制选中

Parameters

BeforeRowSelectEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "originalRowID" : 原行ID "originalRow" : 原行 "rowID" : 行ID "row" : 行 "cancel" : 取消当前操作 }

Return Value

void

public void onCellRender (CellRenderEvent event)

[回调型事件]单元格显示渲染

Parameters

CellRenderEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "rowID" : 行ID "row" : 行 "html" : 输出显示的html,通过修改html影响展现 "colVal" : 列的值 "colName" : 列名 }

Return Value

void

public void onCollapseRow (CollapseRowEvent event)

[回调型事件]树形行折叠

Parameters

CollapseRowEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "rowID" : 行ID "row" : 行 }

Return Value

void

public void onExpandRow (ExpandRowEvent event)

[回调型事件]树形行展开

Parameters

ExpandRowEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "rowID" : 行ID "row" : 行 }

Return Value

void

public void onGroupTextRender (GroupTextRenderEvent event)

[回调型事件]grid分组标题显示渲染

Parameters

GroupTextRenderEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "groupValue" : 分组的值 "summary" : 分组统计定义 "groupText" : 分组显示标题 "count" : 记录数 "groupIndex" : 分组的索引 }

Return Value

void

public void onIndexChanged (IndexChangedEvent event)

[回调型事件]行索引变化

Parameters

IndexChangedEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "originalRowID" : 原行ID "originalRow" : 原行 "rowID" : 行ID "row" : 行 }

Return Value

void

public void onInit (ViewEvent event)

[回调型事件]创建grid组件事件

Parameters

ViewEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 }

Return Value

void

public void onLastEditorPressEnter (LastEditorPressEnterEvent event)

[回调型事件]directEdit=true时最后一行最后一个单元格回车后触发事件

Parameters

LastEditorPressEnterEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "cell" : TD 回车的最后一行最后一个单元格 }

Return Value

void

public void onReload (ViewEvent event)

[回调型事件]grid重新加载

Parameters

ViewEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 }

Return Value

void

public void onRowCheck (RowCheckEvent event)

[回调型事件]多选勾选时,可以使用cancel取消

Parameters

RowCheckEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "rowID" : 对应的行ID "row" : 对应的行 "checked": 勾选状态 "cancel": 取消当前操作 }

Return Value

void

public void onRowChecked (RowCheckedEvent event)

[回调型事件]多选勾选后

Parameters

RowCheckedEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "rowID" : 对应的行ID "row" : 对应的行 "checked": 勾选状态 }

Return Value

void

public void onRowCheckedAll (RowCheckedAllEvent event)

[回调型事件]多选全选

Parameters

RowCheckedAllEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "checked": 勾选状态 }

Return Value

void

public void onRowClick (RowClickEvent event)

[回调型事件]单击行事件

Parameters

RowClickEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "domEvent" : 触发的dom event对象 "rowID" : 对应的行ID "row" : 对应的行 }

Return Value

void

public void onRowDblClick (RowClickEvent event)

[回调型事件]双击行事件

Parameters

RowClickEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "domEvent" : 触发的dom event对象 "rowID" : 对应的行ID "row" : 对应的行 }

Return Value

void

public void onRowSelect (RowSelectEvent event)

[回调型事件]选中行

Parameters

RowSelectEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "rowID" : 行ID "row" : 行 }

Return Value

void

public void onTreeIconRender (TreeIconRenderEvent event)

[回调型事件]树形图标渲染

Parameters

TreeIconRenderEvent event


结构如下:

{ "source" : 组件的js对象, "bindingContext" : 组件绑定的上下文,包含$model、$object等具体请参考bindingContext说明 "rowID" : 行ID "row" : 行 "html" : 输出显示的html,通过修改html影响展现 }

Return Value

void