Creating Kendo Treelist with data from 2 rbf_selectQuery - Forum - Rollbase - Progress Community

Creating Kendo Treelist with data from 2 rbf_selectQuery

 Forum

Creating Kendo Treelist with data from 2 rbf_selectQuery

This question is answered

Hello,

I'm trying to create a Kendo Treelist for my Rollbase portal but I'm running into some difficulties. I want the object to consist of 2 datasources combined, with a hierarchy between them. The object consists of objects and activities. One (sub)object can hold objects or activities. The problem is that I am able to create the correct dataobject, but since there are 2 queries the data is already processed at the first query and therefor incomplete.

Extra explanation: console.log(object); spits out the correct object, but Chrome Devtools notifies me that the value was evaluated only just know. Meaning that the asynchronous object is processed after the tree is generated. The options.success passed the object at the time the first query completed.

Code snippet from the query inside the Datasource => Transport => read():

rbf_selectQuery("SELECT name,id,Ppm_objecten,'object' FROM pm_objecten", 2000, async function(values) {
var arr = values;
if (values.length > 0) {
values.forEach(async (item) => {
await rbf_selectQuery("SELECT name,id,R82743 AS Ppm_objecten,'activiteit' FROM pm_activiteit WHERE R82743=" + item[1], 2000, async function(values2) {
values2.forEach(async (item2) => {
await arr.push(item2);
});
});
});
}
var length = arr.length;
options.success({
total: length,
data: arr
});
});

At data: arr the object is pushed with only the values from the first query, so the pm_objecten. As you can see I've already tried to make it an async function and await the result. 

Does anyone know how to create the full object before sending it to the Kendo TreeList?

Thanks for helping!

Verified Answer
  • The solution was to use a promise in javascript. Create a promise, then for each query an individual promise within the initial promise. The last promise resolves the initial promise and triggers options.success. Thanks for helping!

All Replies
  • Does adding the async: false property to the kendo datasource help?

    stackoverflow.com/.../19651859

  • Thanks for responding Ruben! No unfortunately this does not help. It still only returns the values from the first query.

  • Unsubscribe

  • The solution was to use a promise in javascript. Create a promise, then for each query an individual promise within the initial promise. The last promise resolves the initial promise and triggers options.success. Thanks for helping!