DBTreeview Refresh Data

Hi all,

This time i got a problem with DBTreeView refresh Data.

My initTreeView Method is like followig (which is reference to
http://forum.servoy.com/viewtopic.php?p=49925#49925)


var Binding = elements.dbtreeview.createBinding(controller.getServerName(), controller.getTableName());

//Replace X with the name of the relation that supplied the childNodes for a Node
Binding.setNRelationName(“section_to_section_parent_childs”);

//Replace X with the name of a dataprovider that returns the text for the node
Binding.setTextDataprovider(“displaynode”);

//Sets the global method that gets called when the node is clicked and replace X with the name of a dataprovider will be send as an argument into the globals.XXX method (note: no “()” behind “globals.XXXX”)
Binding.setMethodToCallOnClick(globals.glb_node_selected, “section_id”);

//elements.dbtreeview.createColumn(controller.getServerName(), controller.getTableName(), ‘Description’, ‘description’);

controller.find();

//column_x = “someValueHere”;
section_parent_id =‘^’;

controller.search(false,true);

//set the root node(s) and set the name of dataprovider to use for text display on a node

elements.dbtreeview.addRoots(foundset);


I called above initTreeView Method at the onShow action. and also i called it again after i save new record.

It’s going to refresh the treeview data but the problem is it place duplicate node accoding to last save parent id.

before i save the new record it show as the follwing,

-1
+2
+3
-4
+5
+6

after i save the new record and i re-called initTreeView method, it refresh data and place the duplicate data in treeview like the following,

-1
+2
+3
-4
+5
+6
+7
-4
+5
+6
+7

===========================================

if anybody have solution pls let me know how to do.

Thanks

Dennis

Well, a couple of things:

First of all, you shouldn’t have to init the DBTreeview bean again to get to see the newly added record. This is currenlty not working by default in the bean that ships with Servoy 3.5, but it’s being worked on (issue reported in: 3.5.4 DBTreeView bean: how to use the new functionality - Classic Servoy - Servoy Community).

It does work if you just call teh refresh function on the bean: then the new record should show up.

Thirdly, going about it the way you do, running just the init method again will never work properly, because you do addRoots, which adds new nodes to the DBTreeView bean. If you want to init the bean from scratch (Which is not needed in this case), you would need to call removeAllRoots() first.

Paul

hi pbakker,

first of all thanks for reply.

my problem is if i don’t call the inittreeview method again, child record is fine, after i save the record the child record the treeview shows the new record. but for the parent record it not well at all.

but if i call inittreeview method after new save record, child record is problem but the parent record is working well :(

Cheers

Dennis

Have you tried the refresh suggestion I gave?

hi pbakker,

i already tried your suggestion.

after i save the record i call

dbtreeview.refresh();

but still have the problem.

how to continue with this problem hummm…

S.O.S

Ooops, my mistake. You need to call:

databaseManager.refreshRecordFromDatabase(foundset, -1);

In the code above, foundset is the foundset you added as root.

That should do the trick for now (As was the conclusion at:3.5.4 DBTreeView bean: how to use the new functionality - Classic Servoy - Servoy Community)

Paul

hi pbakker,

thanks indeep for your help.

This time, you solve again for my problem.

i used 'databaseManager.refreshRecordFromDatabase(foundset, -1);".

once i put above coding in method, its working very well.

Cheerio

Dennis