我创建了一个自定义页面,列出了所有打开的工作流程。到目前为止,我一直遵循 Jeff Potts 的教程,但我现在正试图将我的表格更改为更动态的表格,但没有任何成功。
小部件 js 文件如下所示
define(["dojo/_base/declare",
"dijit/_WidgetBase",
"alfresco/core/Core",
"alfresco/core/CoreXhr",
"dojo/dom-construct",
"dojo/_base/array",
"dijit/_TemplatedMixin",
"dojo/text!./templates/AjaxWidget.html",
],
function(declare, _Widget, Core, AlfCoreXhr, domConstruct, array, _Templated, template) {
return declare([_Widget, Core, AlfCoreXhr, _Templated], {
templateString: template,
cssRequirements: [{cssFile:"./css/AjaxWidget.css"}],
i18nRequirements: [ {i18nFile: "./i18n/AjaxWidget.properties"} ],
buildRendering: function example_widgets_AjaxWidget__buildRendering() {
this.widgetTitle = this.message('widgetTitle');
this.columnName = this.message('columnName');
this.columnDescription = this.message('columnDescription');
this.inherited(arguments);
},
postCreate: function example_widgets_AjaxWidget__postCreate() {
var url1 = Alfresco.constants.PROXY_URI + "api/people";
this.serviceXhr({url : url1,
method: "GET",
successCallback: this._getTasksPerUser,
callbackScope: this});
},
_getTasksPerUser: function example_widgets_AjaxWidget__getTasksPerUser(response, config) {
var parentNode = this.containerNode;
var wfUsers = [];
array.forEach( response.people, function(person) {
wfUsers.push(person.userName);
});
for (var wfUser in wfUsers) {
var url2 = Alfresco.constants.PROXY_URI + "api/task-instances?authority=" + wfUsers[wfUser];
this.serviceXhr({url : url2,
method: "GET",
successCallback: this._onSuccessCallback,
callbackScope: this});
}
},
_onSuccessCallback:
function example_widgets_AjaxWidget__onSuccessCallback(response, config) {
var parentNode = this.containerNode;
array.forEach( response.data, function(item) {
var row = domConstruct.create( "tr", {}, parentNode );
domConstruct.create( "td", { innerHTML: item.workflowInstance.id }, row);
domConstruct.create( "td", { innerHTML: item.workflowInstance.message }, row);
domConstruct.create( "td", { innerHTML: item.state }, row);
domConstruct.create( "td", { innerHTML: item.properties.bpm_dueDate }, row);
domConstruct.create( "td", { innerHTML: item.workflowInstance.initiator.firstName + " " + item.workflowInstance.initiator.lastName }, row);
domConstruct.create( "td", { innerHTML: item.owner.firstName + " " + item.owner.lastName }, row);
});
}
});
});
和html模板
<div class="ajax-widget">
<h1>${widgetTitle}</h1>
<div class="div1">
<table>
<thead>
<tr>
<th>Workflow ID</th>
<th>Description</th>
<th>Status</th>
<th>Due Date</th>
<th>Created By</th>
<th>Assigned To</th>
</tr>
</thead>
<tbody data-dojo-attach-point="containerNode"></tbody>
</table>
我尝试使用 List.js 和 DataTables.js jquery 库但没有成功。想要使用这些库中的任何一个的原因是它们提供了我需要的功能。是否有一个易于实现的 dojo 等效项。我全是耳朵。
我的第一个问题是——我是否使用最有效的方法来达到这个结果?在过去的 5 年中,Alfresco 似乎发生了很大变化,很难知道哪些教程/帖子在今天仍然相关。
我尝试使用 dojo 包添加这些库,但是当我查看源代码时,我看不到它们是否可用,并且当我在 js 文件中使用“require []”关键字时,它似乎没有效果。
如果我要走正确的道路,我将如何使我的表格可排序和可搜索。如果我在吠叫错误的树,请指出我正确的方向。
谢谢 - 欢迎所有建议:-)