[ODK-X Tables] passing on variables when redirecting from one tables to another

What is the problem? Please be detailed.
I have a survey and a table with data on villages and a linked table in which i enumerate households in each village. I use ODK-X-tables to show a list of villages and when I click on one, it should move on to a list of households. I’ve been following the HOPE example and made sure that by clicking on a village one is taken to the _list view of the households in that village:

function handleClick(comId) {
    if (!$.isEmptyObject(networksCommunity)) {
        odkTables.openTableToListView(null,
                'networksHouseholdList',
                'comId = ?',
                [comId],
                'config/tables/networksHouseholdList/html/HouseholdList_list.html');
    }
}

So far this works like charm. However, my code on the sub view (HouseholdList_list.html) needs to use the comId that it was called from (to add a button that allows users to add new households). How to I read that information from within HouseholdList_list.html?

What ODK tool and version are you using? And on what device and operating system version?
ODK Survey 2.1.8
ODK Tables 2.1.8

What you have you tried to fix the problem?
Also adding the ComId to the path, like: ‘HouseholdList_list.html?comId=’+comId. But this is a hacky solution that is bound to cause problems.

I’ve also tried reading the ComId from the objects in the returned table in the subview, but that fails when the list is empty.

Hi @Simon_Hess!

I am not super familiar with the html and ODK-X Tables display component, but it sounds like what you are trying to do is feed data from a “parent” form to a sub-form, specifically the community identifier. I have done something similar before using the queries sheet: ODK-X XLSX Converter Reference — ODK-X Docs and specifically the newRowInitialElementKeyToValueMap
There’s an example with putting the household id with members here: Using ODK-X XLSX Converter — ODK-X Docs and you would do something similar to put a community id with households.

I am not sure I completely understand your problem.

One approach is to save the data in database row and then launch Survey on that database row so you always have a pointer to it.

2 Likes