How to use dojo.ready or dojo/domReady! with EWM custom presentation?
Hello,
|
2 answers
Lawrence Smith (376●4)
| answered Dec 02 '20, 11:27 a.m.
JAZZ DEVELOPER edited Dec 02 '20, 11:29 a.m.
Hello... The workitem code does not use dojo DataGrid. It also does not use the domReady calls of base dojo. Here are some things to try:
1) Check that the require statements include all the elements referenced. Sometimes if a require is not included then the order in which a component is loaded will determine if a non-specified required component is already loaded or missing, meaning that it will not render on first load but would render on refresh. The fix is to add all the require statements.
2) Use a setTimeout to defer loading of the grid until the target element is available in the dom. Something like (untested psuedocode)...
postCreate(): function {
...
waitAndRender(6000); // * 100 ms
...
}
waitAndRender: function(count) {
if (count<=0) {
console.log("Page not loaded for...");
return; // fail
}
window.setTimeout(dojo.hitch(this, function() {
if (this.elementLoaded()) {
this.doRenderGrid();
} else {
this.waitAndRender(count-1); // stop after so many tries
}
}), 100);
}
3) Use page lifecycle events. This is a hack since it uses internal events but there are a few events (see EventTopics.js) that are published...
// EventTopics.WORKITEM_PAGE_LOADED= "rtc/workitems/page/loaded"
// EventTopics.WORKITEM_VIEW_CHANGED= "workitem/view/changed"
var handle= dojo.subscribe("rtc/workitems/page/loaded", this, doRenderGrid);
// remember in the destroy method or sooner to unsubscribe
onDestroy... dojo.unsubscribe(handle).
4) If the widget itself is not loading, try a super simple version that just renders a text div or something to see that it is loading, then add in the required components until it fails.
For further analysis we would need to look at the code including the requires and postCreate, and how the contribution is specified.
Regards,
Lawrence
Comments
Hello Lawrence,
Thank you for your help. Here is my latest post with more details:
1) The require statements look complete.
2) I tried setTimeout to defer loading of the grid but that didn't help.
3) I tried the page lifecycle events.
4) Text does get displayed in the <div>. I tried just DataGrid with no data (only headers ) but same result.
In summary, it all works great until I revisit a WI that I have visited before. When I navigate to a new WI then the Widget constructor and postCreate are called - and it all works great. But when I visit a previous WI (that worked great the first visit) then the DataGrid does not render. It will render if I then hit the yellow refresh since it at this points calls the constructor and postCreate. It all fails when the current Widget instance is reused against a previous WI.
This is a rendering problem with the dojo.DataGrid which is not used in Work Items. the DataGrid may require dojo calls to destroy the old one and recreating it when the widget is in view. Or there is a dojo version or library incompatibility. I searched for DataGrid and found it referenced in dojox.grid library. Maybe this is being overlaid with a dojo library that does not have DataGrid. |
Please keep the post to one question thread.
DataGrid may be designed to be a singleton. The source code for it shows it uses some kind of store. Be sure the store is cleared and refreshed when switching items. Debug into DataGrid and see what it is doing. use the ?debug=true#action= to look at the code.
If the class itself is somehow being overwritten... then maybe try not using DataGrid or copy the DataGrid class locally and rename it and use that to see if it is some kind of dojo conflict.
Comments
Kevin Johnson
commented Dec 04 '20, 3:40 p.m.
Hello Lawrence, thank you for your help. I've been reading and re-reading your comments above and still trying to understand what I need to change/fix.
It looks like the DataGrid is either implemented as a singleton or there is a problem in the usage such as passing the same store to two DataGrid. When you switch work items it may be that the prior DataGrid has to be removed then a new one added to the new work item, and a new store provided. Perhaps publishing an event that is subscribed by the widget to move it to the work item when it is presented. I have not looked at this component.
Looking at the SubscribersPart there is a refresh on showWidget and when the working copy changes. The showWidget is called automatically and the work item change is subscribed to (and unsubscribed on destroy):
showWidget: function() {
if(this._isInitialized) return; this._isInitialized = true; this.refresh(); },
The work item change is subscribed to (and unsubscribed on destroy):
_handleWorkingCopyChange: function(parms) {
this.refresh();
}
---
this.workingCopy.addListener({
path: path, event: "onchange", listener: this, functionName: "_handleWorkingCopyChange" }); Is the class inheritance correct? The documentation shows...
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.