Page 1 of 1

Refresh DataGrid/Treeview when card closes

Posted: Tue Aug 15, 2017 3:35 am
by mrk
Hello

I'm sure I'm missing something basic but I have to ask....
I have a treeview field on my "Main" card. I open a separate sub stack (Add Equipment - Card02) to administer the adding of child nodes (done by reading a SQL table of available selections, the selections are then added to the SQL table which builds the treeview). What I want to do is have the treeview refresh/rebuild to reflect the changes once I submit and close the Add Equipment page.
On the "Main" card I have a button "Build Tree" which runs to SQL connection string and populates the treeview.
I have tried to make the script a function which the button calls (this works), but I cant seem to call it when I close the other card.
Below are a couple of lines of code I have tried to use

-- send "mouseUp" to card "Main" to button bBuildTree
-- dispatch "BuildTree" to card "1002"

The error usual generated is "(Chunk: cant find card)"

Thanks

Re: Refresh DataGrid/Treeview when card closes

Posted: Tue Aug 15, 2017 10:15 am
by mrk
Okay, I think I've found a way.
On the Card that has the Treeview I have inserted the following into the Card Script

on resumeStack
BuildTree --"The function I have that re-queries SQL and redraws the treeview"
end resumeStack

As a side note, is there a way to determine if the Stack is being Opened? I had the command running in an OnOpenStack function, but it would redraw twice when first opened.

Re: Refresh DataGrid/Treeview when card closes

Posted: Tue Aug 15, 2017 10:55 am
by jmburnod
Hi mrk,
is there a way to determine if the Stack is being Opened?
Yes :D
openstacks function return a list of the short name of opened stacks
stacks function return a list of file paths of open stacks, on per line
Best regards
Jean-Marc

Re: Refresh DataGrid/Treeview when card closes

Posted: Tue Aug 15, 2017 12:18 pm
by mrk
That's interesting, I may have a use for that information. I don't think I worded my question properly....sorry.
Let's try again.....
I need the view rebuilt when the Card initially opens -- I have this working.
What I need to do is not have the "on resumeStack" fire when the card is initially opening as if forces the tree to redraw twice making the tree appear to flicker.

Basically a way to check if the stack is opening not just "refreshing"

Re: Refresh DataGrid/Treeview when card closes

Posted: Tue Aug 15, 2017 12:18 pm
by mrk
That's interesting, I may have a use for that information. I don't think I worded my question properly....sorry.
Let's try again.....
I need the view rebuilt when the Card initially opens -- I have this working.
What I need to do is not have the "on resumeStack" fire when the card is initially opening as if forces the tree to redraw twice making the tree appear to flicker.

Basically a way to check if the stack is opening not just "refreshing"

Re: Refresh DataGrid/Treeview when card closes

Posted: Tue Aug 15, 2017 1:02 pm
by Klaus
Hi mrk,

you have used a wrong syntax here:
...
## Start from object you want to send something to and then up the object hierarchy:
send "mouseUp" to button "buildtree" of card "Main"
...
## A card (any control) must not have a number as its name!
## Here you want to refer to the ID of the card, if it has no name.
dispatch "BuildTree" to card ID 1002
...

Best

Klaus