1、自定义column
PrcEditDataset.prototype.createGridColumns = function () {
var _this = this;
var columns1 = [
{
field: "propertyName",
label: " ",
sortable: false,
autoSave: true,
renderCell: function (object, data, td) {
return _this.renderSelectWidgetCell(object, data, td);
}
}
];
};
// 这是为了做2部分列,如2列固定,其他列可以滚动
//this.datasetTable.set('columnSets', [columns1,colums2]);
//常用的设置columns
//this.datasetTable.set('columns', columns1);
2.context menu
this.datasetTable.on(".dgrid-cell:contextmenu", (event) => this.onShowGridContextMenu(event));
PrcEditDataset.prototype.onShowGridContextMenu = function (event) {
event.preventDefault();
var menu = Dijit.Factory.createMenu({
onClose: function () {
menu.destroyRecursive();
}
});
var menuSeparator = Dijit.Factory.createMenuSeparator({
});
var menuCheckedItem = Dijit.Factory.createCheckedMenuItem({
});
// add column
menu.addChild(Dijit.Factory.createMenuItem({
label: "Add column",
onClick: function () {
alert("dd000xxx");
Dijit.popup.close(menu);
}
}));
this.showContextMenu(event, menu);
};
3. 是否显示 header
this.grid.set("showHeader", isShow);
PrcEditDataset.prototype.showContextMenu = function (event, menu) {
if(event.pageX != 0 && event.pageY != 0) {
Dijit.popup.open({
popup: menu,
x: event.pageX,
y: event.pageY,
onCancel: function () {
Dijit.popup.close(menu);
}
});
Dojo.once(Dojo.Dom.byId("appContainer"), "touchstart", function () {
return Dijit.popup.close(menu);
});
Dojo.once(Dojo.Dom.byId("appContainer"), "mousedown", function () {
return Dijit.popup.close(menu);
});
}
};
4、双击可编辑column
var columnWidget = Dgrid.Factory.createEditor({
label: header,
field: field,
sortable: canSort,
dismissOnEnter: true,
width: defaultWidth ? defaultWidth : columnWidth,
editOn: "None"
});
columnWidget["canEdit"] = function () { return this.gridModel.canEdit; };
columnWidget["editor"] = DashboardCellWidget.Factory.createDashboardCellWidget;
columnWidget["editorOn"] = "dblclick";
columnWidget["editorArgs"] = {
clickEvent: this.callback.getPropBtnClickCallback(),
obj: this,
onClearEvent: this.clearProperty
};
if (!Utilities.Utils.isUndefined(this.cellHandler)) {
columnWidget["renderCell"] = this.cellHandler;
}
if (!Utilities.Utils.isUndefined(this.cellHandler)) {
columnWidget["renderHeaderCell"] = this.headerCellHandler;
}