Refresh DataGrid/Treeview when card closes

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
mrk
Posts: 19
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Refresh DataGrid/Treeview when card closes

Post by mrk » Tue Aug 15, 2017 3:35 am

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

mrk
Posts: 19
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Re: Refresh DataGrid/Treeview when card closes

Post by mrk » Tue Aug 15, 2017 10:15 am

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2559
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Refresh DataGrid/Treeview when card closes

Post by jmburnod » Tue Aug 15, 2017 10:55 am

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

mrk
Posts: 19
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Re: Refresh DataGrid/Treeview when card closes

Post by mrk » Tue Aug 15, 2017 12:18 pm

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"

mrk
Posts: 19
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Re: Refresh DataGrid/Treeview when card closes

Post by mrk » Tue Aug 15, 2017 12:18 pm

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"

Klaus
Posts: 12117
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Refresh DataGrid/Treeview when card closes

Post by Klaus » Tue Aug 15, 2017 1:02 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”