时刻列中的触发函数在GridX中排序
Posted
技术标签:
【中文标题】时刻列中的触发函数在GridX中排序【英文标题】:Trigger function in moment column is sorted in GridX 【发布时间】:2018-08-05 06:20:07 【问题描述】:我在 Gridx 中使用 SingleSort 模块。我找不到(我已经检查了 SingleSort 文档但一无所获)对排序事件做出反应的方法。我需要有关对哪个(以及如何)列进行排序的信息。我知道如何获取有关排序的信息(getSortData 方法),但我不知道如何在排序时做出反应。我无法创建 onRender-event 函数,因为排序后我会将该信息发送到 webapi 获取新数据并再次渲染 Grid,因此将再次触发事件。
define([
"dojo/Evented",
"dojo/_base/declare",
"dojo/store/Memory",
"gridx/core/model/cache/Sync",
"gridx/Grid",
"gridx/modules/ColumnResizer",
'gridx/modules/Focus',
'gridx/modules/RowHeader',
'gridx/modules/select/Row',
'gridx/modules/select/Column',
'gridx/modules/select/Cell',
"gridx/modules/SingleSort"
], function (Evented, declare, Memory, Cache, Grid, ColumnResizer, Focus, RowHeader, SelectRow, SelectColumn, SelectCell, Sort)
return declare([Evented],
_counter: 1,
_topOffset: 100,
constructor: function ()
,
initialize: function ()
this._initGrid();
this._resizeGridContainer();
,
clear: function ()
var store = new Memory( data: [] );
this._grid.setStore(store);
this._counter = 1;
,
_initGrid: function ()
var _this = this;
var store = new Memory(
data: []
);
var structure = [
id: 'operationType', field: 'operationType', name: dojo.byId(this._operationTypeId).value
,
id: 'transportationType', field: 'transportationType', name: dojo.byId(this._transportationUnitTypeId).value
,
id: 'transportationTypeLength', field: 'transportationTypeLength', name: dojo.byId(this._transportationLengthId).value
]
this._grid = Grid(
id: this._gridId,
cacheClass: Cache,
store: store,
structure: structure,
modules: [
ColumnResizer,
Sort
],
selectRowTriggerOnCell: true
);
this._grid.placeAt(this._gridPlaceholderId);
this._grid.startup();
,
_resizeGridContainer: function ()
var _this = this;
var container = dojo.byId(this._gridContainerId);
var height = container.parentElement.clientHeight - this._topOffset;
require(["dojo/dom-style"], function (domStyle)
domStyle.set(_this._gridContainerId, "height", height + "px");
)
,
);
);
【问题讨论】:
【参考方案1】:你需要像这样点击 gridx SingleSort 模块排序方法
this._grid.connect( this._grid.Sort, 'sort', function(colId, isDescending, skipUpdateBody)
alert(colId+" "+isDescending+" "+skipUpdateBody);
);
这将在对网格列进行排序时触发事件。希望这会有所帮助。
【讨论】:
以上是关于时刻列中的触发函数在GridX中排序的主要内容,如果未能解决你的问题,请参考以下文章