SmartGWT: v8.2p_2012-10-06/PowerEdition Deployment (built 2012-10-06)
Browser: FF 15, Chrome 22.
There are a few issues I've encountered while trying to use an IPickTreeItem, I'll try and step through each one.
I'm using a SQLDataSource, here is my test data:
Here is the datasource:
Here is some base code:
And the DMI in question:
1) I can't seem to find a way to override the "Choose a value" default message in the IPickTreeItem
I was expecting setEmptyDisplayValue to do the job.
2) If I want to load a value, it seems the IPickTree shows the value instead if display value if the tree isn't loaded beforehand
I've used form.setValue("tree_id", 4) in the above example, but the form could be loading from another datasource and it would have the same effect - if setLoadDataOnDemand is true, it does not seem to be able to resolve the id value of 4 to the correct display value of "Item 2", regardless of what has been set into setFetchMissingValues and setAlwaysFetchMissingValues. When setLoadDataOnDemand is true, Developer Console shows the two root values being returned, followed by a second RPC requesting:
And the correct response comes back:
So this behaviour as far as the RPCs go appear to be correct. However, the GUI will still display only the value of 4, rather than the display value. I stress that this works if setLoadDataOnDemand is false (presumably because the entire tree has been preloaded)
3) setOptionOperationId is not respected?.
As you can see I use the DMI to manually manipulate the results so that the IPickTree doesn't shown an empty menu for leaf items. This works, but for cleanliness I wanted to tie this behaviour down to a specific operationId only.
(the commented line of code setOptionOperationTypeId("pickTreeFetch") is then used in the datasource definition also:
Below is a screenshot of the RPCs fired:
RPC #0: initial call when the paged loaded, retrieves the two root values.
RPC #1: the request made by the IPickTreeItem for id=4 (returns correctly but doesn't show the correct display value on the GUI)
RPC #2: I navigate to "Group 1" on the IPickTreeItem, "Item 1" and "Item 3" are returned, however, this request was not done through the DMI, resulting in Item 1 and Item 3 both showing an empty menu, even though they are leaf items.
Any suggestions/comments on the above welcomed!
All the above behaviour occurs in both FF and Chrome, dev and compiled.
Browser: FF 15, Chrome 22.
There are a few issues I've encountered while trying to use an IPickTreeItem, I'll try and step through each one.
I'm using a SQLDataSource, here is my test data:
Here is the datasource:
Code:
<DataSource ID="tree_test" serverType="sql" tableName="tree_test" autoDeriveSchema="true"> <fields> <field name="parent" type="text" hidden="true" rootValue="root" foreignKey="tree_test.name"/> </fields> <operationBindings> <!-- need to include injected isFolder value here --> <operationBinding operationType="fetch" outputs="id,parent,name,isFolder"> <serverObject className="com.test.server.dmi.TreeTestDMI" methodName="pickTreeFetch"/> </operationBinding> </operationBindings> </DataSource>
Code:
/** * This is the entry point method. */ public void onModuleLoad() { IPickTreeItem cmbPickTree = new IPickTreeItem("tree_id", "Pick Tree Test"); cmbPickTree.setOptionDataSource(DataSource.get("tree_test")); cmbPickTree.setCanSelectParentItems(false); cmbPickTree.setLoadDataOnDemand(false); // TODO display value doesn't show properly if not loaded cmbPickTree.setFetchMissingValues(true); // TODO don't seem to work if loadOnDemand=true cmbPickTree.setAlwaysFetchMissingValues(true); // cmbPickTree.setOptionOperationId("pickTreeFetch"); // TODO no effect cmbPickTree.setValueField("id"); cmbPickTree.setDisplayField("name"); cmbPickTree.setEmptyDisplayValue("Empty"); // TODO no effect DynamicForm form = new DynamicForm(); form.setFields(cmbPickTree); form.setWidth100(); form.setHeight100(); form.setValue("tree_id", 4); form.draw();
Code:
public DSResponse pickTreeFetch(DSRequest dsRequest) throws Exception { DSResponse response = dsRequest.execute(); // leaf items aren't folders @SuppressWarnings("unchecked") ArrayList<HashMap<String, String>> dataList = (ArrayList<HashMap<String, String>>)(response.getData()); for (HashMap<String, String> map : dataList) { map.put("isFolder", String.valueOf(map.get("parent").equals("root"))); } return response; }
I was expecting setEmptyDisplayValue to do the job.
2) If I want to load a value, it seems the IPickTree shows the value instead if display value if the tree isn't loaded beforehand
I've used form.setValue("tree_id", 4) in the above example, but the form could be loading from another datasource and it would have the same effect - if setLoadDataOnDemand is true, it does not seem to be able to resolve the id value of 4 to the correct display value of "Item 2", regardless of what has been set into setFetchMissingValues and setAlwaysFetchMissingValues. When setLoadDataOnDemand is true, Developer Console shows the two root values being returned, followed by a second RPC requesting:
Code:
"data":{ "id":4 }, "callback":{ "target":[IPickTreeItem ID:isc_IPickTreeItem_1 name:tree_id], "methodName":"fetchMissingValueReply" },
Code:
data:[ { id:4, isFolder:"false", name:"Item 2", parent:"Group 2" } ],
3) setOptionOperationId is not respected?.
As you can see I use the DMI to manually manipulate the results so that the IPickTree doesn't shown an empty menu for leaf items. This works, but for cleanliness I wanted to tie this behaviour down to a specific operationId only.
(the commented line of code setOptionOperationTypeId("pickTreeFetch") is then used in the datasource definition also:
Code:
<operationBinding operationType="fetch" operationId="pickTreeFetch" outputs="id,parent,name,isFolder">
RPC #0: initial call when the paged loaded, retrieves the two root values.
RPC #1: the request made by the IPickTreeItem for id=4 (returns correctly but doesn't show the correct display value on the GUI)
RPC #2: I navigate to "Group 1" on the IPickTreeItem, "Item 1" and "Item 3" are returned, however, this request was not done through the DMI, resulting in Item 1 and Item 3 both showing an empty menu, even though they are leaf items.
Any suggestions/comments on the above welcomed!
All the above behaviour occurs in both FF and Chrome, dev and compiled.
Comment