Hi All,
I am currently using the DB TreeView bean. Depending on the search condition I want display the nodes depending on the two separate relations . The sample code is as follows :
if(condition 1)
binding.setNRelationName(‘rel1’)
else if(condition 2)
binding.setNRelationName(‘rel2’)
Suppose for the first time the condition 1 satisfies , it is displaying correctly according to the first condition. Then after that condition 2 satisfies but the bean is not refreshing correctly according to the second condition. But for the first time we are doing , both the cases are working fine. But the second time onwards , for the other condition it is not refreshing correctly.
Can we display using 2 relations depending on condition. Is it possible ?. Please do help.
Thanks in advance . Waiting for your feedback.
Hi All ,
I meant to say that is it not possible to dynamically change the relation of the tree bean depending on some criteria. Is there some issue with it ?. Please do reply . I am waiting for your feed back.
Thanks,
Ashutos.
you should call the refresh function of the bean
Hi Gabi ,
Thanks for your reply. I have already tried with the Refresh function. But still it is not working. Please do help.
Thanks in advance. Waiting for your feedback.
I just tried it with refresh, and it does work on my side;
can you upload a sample where this is not working ?
Hi Gabi ,
Thanks for your reply. Please find the attached solution for the Tree Bean . The tree is displayed in the first form of the solution . There are two buttons Search 1 and Search 2 in this form.On clicking of the two buttons it displays two corresponding tree views. There is one parent record for both searches . But for the first search there is two child record and for the second search there is only one child record . The two searches are based on two different relationships . But it is not refreshing correctly . But on the reopening of the smart client it working perfectly . Please check the following Issue.
Thanks in advance . Waiting for your feedback.
TreeTest.servoy (6.16 KB)
Hi All,
Please do reply for my post . I have already sent a sample solution which contains the mentioned issue .I hope some feedback on that.
Thanks in advance . Waiting for your feedback.
hi ashutos,
the problem is that dbtreeview does not support creating multiple bindings for
the same datasource, so when you press the second search, it creates a new binding
for the same datasource, but with diff relation, and that is ignored.
change your code, so you have only one binding for the ds, and change on that the relation
you want to use, when clicking on diff search buttons
Hi Gabi ,
Thanks for your reply . Actually in the sample solution my two different bindings are based on two different datasources . Actually the root node is based on one table and the child nodes are based on another table . So I need to create two different bindings for that. In the real project situation it is also the problem . Is it not currently possible in servoy 6.0. ?
Thanks in advance . Waiting for you feedback.
the fact that you have 2 binding for 2 different datasources is correct,
but you create the 2 bindings each time the search button is clicked, and so,
on the second click on the button, the newly created bindings are ignored, this is
why, the tree is not changing, as it will always use the first created bindings
Hi Gabi ,
Thanks for your reply . But two binding are mandatory for two different data sources . So we cannot change it to one binding.
In my real project situation when I am clicking “Search1” button multiple times it is not creating any problem . In search 1 if my search criteria are changing and then it is correctly displaying the tree . But after that when I am clicking “search2” based on a different relation it is not working . suppose on “search 1” I want to do title search and on the “Search 2” I want to do the Date Time search.
Thanks in advance . Waiting for your feedback.
I have not tried, but maybe using setNRelationDataProvider instead of setNRelationName could work.
If the provider is a calculated field that returns the name of the relation based on your condition.
As I said I have not tried but it could work.
here is your code changed, so you can understand what I was meaning :
/**
* @properties={typeid:35,uuid:"CA5DDF41-A1F3-42EE-BE27-E366A340D123",variableType:-4}
*/
var empBinding = null;
/**
* Perform the element default action.
*
* @param {JSEvent} event the event that triggered the action
*
* @properties={typeid:24,uuid:"69E4D24D-1537-4A57-B011-967BFEF39BC6"}
*/
function searchTree(event) {
elements.bean_tree.removeAllRoots();
// Employee Binding.
if(!empBinding) empBinding = elements.bean_tree.createBinding(foundset.getDataSource());
empBinding.setTextDataprovider('emp_name');
// Two different relation.
if(event.getElementName() == 'search1'){
//elements.bean_tree.refresh();
empBinding.setNRelationName('emp_to_gadjets');
}
else{
//elements.bean_tree.refresh();
empBinding.setNRelationName('emp_to_gadjets$software');
}
// Gadjet binding.
var gadjetsBinding = elements.bean_tree.createBinding('db:/bug_db/gadjets');
gadjetsBinding.setTextDataprovider('gadjet_name');
elements.bean_tree.addRoots(foundset);
}
Hi Jasantana ,
Thanks for your help .It is working fine . ![Very Happy :D]()
Hi Gabi ,
Thanks for your reply . I hope so it will also work well.