cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Tree Grid Service isn't working

Ike@ACE
15-Moonstone

Tree Grid Service isn't working

I'm building a mashup that is an experience portal. A user will log-in and use the portal to view which experiences they have access to and other data associated with those experiences. One of the types of experiences I have requires the user to use it multiple times. I want to allow the user to see the history of use by using a tree grid. I only need to go down one level of children, and not every experience needs children. I've already figured out how to show the expandability of a row, my problem is getting the child data to show up. I've written a service that should work (I'll share it below), but the children don't show up. Any help would be greatly appreciated.

 

//input: selectedExperience (InfoTable DS: AR_ExperiencesForGroups)
//    brought in by SelectedRow in the mashup

 

let result;

// result: STRING
let username = Resources["CurrentSessionInfo"].GetCurrentUser();

 

if (selectedExperience.rows[0].hasChildren) {
    //Example experience name: "GBU-10 Quiz, Online"
    let experienceName = selectedExperience.rows[0].ExperienceNameAlias;
    let experienceSplit = experienceName.split(' ');
    let arr;
    for (arr = 0; arr < experienceSplit.length; arr++) {
        if (experienceSplit[arr] != '') {
            break;
        }
    }
    let experienceWeapon = experienceSplit[arr];
    if (experienceWeapon.includes('-')) {
        let weaponSplit = experienceWeapon.split('-');
        experienceWeapon = weaponSplit[0] + weaponSplit[1];
    }
    //Tables have a standard naming convention that this follows
    let resultsTableName = username + '_' + experienceWeapon + '_ResultsDataTable';
    try {
        // result: INFOTABLE dataShape: "Results_For_IndividualsDT"
        result = Things[resultsTableName].GetDataTableEntries({
            maxItems: 50 /* NUMBER */
        });
    } catch (err) {}
}

6 REPLIES 6
c_lowy
16-Pearl
(To:Ike@ACE)

Hi Ike@ACE,

 

Here is the link to some Advanced Grids Samples File which also contain examples for the Tree Grid widget (HierarchicalPartsExample mahup) in case it can help. The data for the Tree Grid in this example is retrieved from a datatable called PartsTable and then parsed by a service called GetPartsData on the GridAdvancedExampleServices Thing. 

Ike@ACE
15-Moonstone
(To:c_lowy)

Thanks for the prompt response. I have already tried looking through all of that to try and figure out what I'm doing wrong and it just about made my head explode. I didn't really understand how it was working or how to get it to work. From what I understood, it was creating the tree structure dynamically, which is not really what I need anyway. After all, I'm trying to pull data from multiple data tables, not just one. The first data table will have all of the parent rows and the second set of data tables will populate the child rows of the parent rows that do expand.

c_lowy
16-Pearl
(To:Ike@ACE)

Looking at your script, is my understanding correct that the data you actually want to display in your Tree Grid is the data from a DataTable (resultsTableName, depending on user) ?

 

If so, the fact that you are missing the children rows might be due to missing the isParent column in your DataTable. The DataTable populating the Tree Grid Advanced needs a hasChildren column :

  • Include column defining whether row has children or not: basetype can be Boolean (true = row has children), Number or String (1 = row has children)
  • Set hasChildren parameter of Tree Grid Advanced widget to the name of the above mentioned column

​​​​​​​

Ike@ACE
15-Moonstone
(To:c_lowy)

Let me just make sure that I'm reading this right. You're saying that the top row needs <hasChildren> and the child rows underneath of it need <isParent>? Or do all entries need both? 'Cause my parent rows have the have the <hasChildren> property, but my child rows have neither of these. Also, I'm not sure if you noticed, but there are two different data shapes being used. Is that legal? Or do they need to be the same?

c_lowy
16-Pearl
(To:Ike@ACE)

Hi Ike@ACE,

 

I have made some additional tests and the hasChildren column is not required to actually display the children nodes. It is however required for some other functionalities like "ExpandRowOnDoubleClick" as per In ThingWorx Tree Grid Advanced widget ExpandRowOnDoubleClick option does not work for expanding but only for collapsing. In general it is advised to have a hasChildren column that you can map to the "HasChildrenFieldName" parameter of your Tree Grid Advanced.

 

I don't know anything about having to have a isParent column though, I would rather advise to have a ParentID column + hasChildren.

 

Regarding your service I am really not sure why it is not showing the child data in your mashup. If the content of your DataTable looks something like what is shown in the attached screenshot you should be able to display your data at runtime. I am also attaching the entities in case they can help. Also note that there is an example set of entities available under 

Advanced Grids Samples File that can help with Working with Tree Grid Data.

slangley
23-Emerald II
(To:Ike@ACE)

Hi Ike@ACE.

 

If one of the previous responses helped you to find a solution to your problem, please mark the appropriate one as the Accepted Solution for the benefit of others with the same issue.

 

Regards.

 

--Sharon

Announcements


Top Tags