Edit: It seems the correct values are stored in listWidget.children._values
instead of just listWidget.children
. It seems strange to me that the children would still contain those old row keys and null values though.
I'm trying to create a list whose datasource is another datasource's item's relation. For example: I have two tables, one storing roles and another storing permissions and I have a one to many relation between roles and permissions. Both the roles
and permissions
tables have a name
property.
I have a list with datasource roles
to select a role. Each row has a button with the following code for the onClick event:
app.datasources.roles.selectKey(widget.datasource.item._key);
app.showPage(app.pages.listView);
I'm not sure if this is the best practice but it sets the current role item to the key stored in the roles
list's row's datasource key.
The listView page has another list, this time having a datasource of @datasources.roles.item.permissions
to load rows from the current role's permissions. I then have a simple label to output that permission's name.
The permission list loads just fine the first time, with the list widget's children containing the correct rows but when you go back to the role selection page and click another role's button the widget seems to go to an invalid state with the children keys staying as the old rows and the values null. I have an event on the row's onDataLoad to output the row widget and I can see that the new rows are being loaded and linked to the parent widget (the list itself) but if I go back to the children of that widget the values are still null.
For example let's say I have two roles:
key | name
===========
1 | role1
2 | role2
and the following permissions:
key | name | role_fk
=====================
1 | perm1 | 1
2 | perm2 | 1
3 | perm3 | 2
When I click the button to load role key 1
and show it's permission list I get the correct list:
Permission List:
================
perm1
perm2
And when I check the list widget I also see the correct children: "List1Row$0", "List1Row$1"
. However, once I go back and click to load role key 2
I still have children "List1Row$0", "List1Row$1"
, their values are null, and the list shows:
Permission List:
================
perm3
I know the perm3
widget is being created as I have it print to console when it's attached. One strange thing is that it's name is "List1Row$2"
, suggesting that the old row values were never cleared out.
Anyone know how to fix this? I can link a sample app which is as simple as I could make while still exposing the issue. I'm not sure if you're able to use item relations as list datasources or if there's an issue with how I'm selecting my datasources, items, and bindings.
Here is some additional output, the point where the list is detatched is where I go back and click to set the page item to the second item.
Loaded row with name List1Row$0
Loaded row with name List1Row$1
Widget Child - Key: __gwt_instance Null? No
Widget Child - Key: _values Null? No
Widget Child - Key: List1Row$0 Null? No
Widget Child - Key: List1Row$1 Null? No
------- Detatching List -------
Loaded row with name List1Row$0
Loaded row with name List1Row$1
Loaded row with name List1Row$2
Widget Child - Key: __gwt_instance Null? No
Widget Child - Key: _values Null? No
Widget Child - Key: List1Row$0 Null? Yes
Widget Child - Key: List1Row$1 Null? Yes
Thanks.