-
1. Re: Updating records after loading more on list view
Ccchow-Oracle Aug 7, 2019 10:50 PM (in response to Luiz B)Hi Luiz,
You said you did model.set on the new data 'right after loading additional set of data', did you use method or event on Collection to find out when that happens? Ideally, you would want the model to be change with the new property before it gets to ListView, which you can do through Model extend (http://jet.us.oracle.com/trunk/jsdocs/oj.Model.html#extend , using one of the callbacks)
I think your approach is not working because you are updating the model with the new property before they are rendered by ListView but after they are in the Collection. That's why adding a timeout works.
Thanks,
Chadwick
-
2. Re: Updating records after loading more on list view
Luiz B Aug 8, 2019 5:39 PM (in response to Ccchow-Oracle)Hi Chadwick,
Thanks for your reply,
I am using events on Collection; however, no specific event was triggered when new data was loaded, so I triggered it using collection.trigger() when I got the response from web service.
The problem of changing the new properties before records get to ListView is that these new modified properties are fetched from different web services (another fetch call) and that would slow things down a lot.
-
3. Re: Updating records after loading more on list view
Ccchow-Oracle Aug 8, 2019 11:26 PM (in response to Luiz B)Right, no events on Collection is fired because CollectionTableDataSource explicitly suppresses Collection events from firing.
Alternatively, you could listen for 'sync' event from CollectionTableDataSource instead:
this.datasource.on("sync", function(event) {
var startIndex = event.startIndex;
// call my webservices at this point
....
var busyContext = Context.getContext(ojlistview_elem).getBusyContext();
busyContext.whenReady().then(function(){
// but update model here
});
});
You'll have to update the models after the items are rendered, and you can do that using the BusyContext.
-
4. Re: Updating records after loading more on list view
Luiz B Aug 9, 2019 4:08 PM (in response to Ccchow-Oracle)Thanks Chadwick,
I am currently using CollectionDataProvider, instead of CollectionTableDataSource since it was deprecated in the newer versions I believe (I can't see its API documentation in the newer docs).
I was checking CollectionDataProvider API: https://docs.oracle.com/en/middleware/developer-tools/jet/7.1/reference-api/oj.CollectionDataProvider.html, and it doesn't have a .on method. Will the .addEventListener work the same as .on? Or do you have any suggestion for using that with CollectionDataProvider?
-
5. Re: Updating records after loading more on list view
Ccchow-Oracle Aug 9, 2019 4:24 PM (in response to Luiz B)Right, unfortunately CollectionDataProvider do not fire an equivalent event.
I would for now use CollectionTableDataSource to get you unblock, and at the same time file an ER for an DataProvider event that is fired whenever a fetch happens. I have seen multiple use case of something similar before, so I think it's worthwhile we look into supporting this kind of use case.
-
6. Re: Updating records after loading more on list view
Luiz B Aug 12, 2019 6:07 PM (in response to Ccchow-Oracle)Thank you Chadwick.
Do you have an idea if that will be supported in next releases of JET? If so, when?
Currently, I have been triggering an event after getting a response from server and setting a busy context for the list view, so that i just update my models after list view is ready.
-
7. Re: Updating records after loading more on list view
Ccchow-Oracle Aug 13, 2019 5:20 PM (in response to Luiz B)So just to confirm when your busy context is resolve and you are updating the Model object, the items in ListView are already rendered? If that is the case it should work. ListView should be getting an update event from the Collection and display the updates in the list.
-
8. Re: Updating records after loading more on list view
Luiz B Aug 14, 2019 1:03 PM (in response to Ccchow-Oracle)Yes, in that case it works.
I was just wondering if you have any plans to release methods like .on() for DataProviders as well for future JET releases.
Thank you.