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. |