modal stack behavior

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

modal stack behavior

Post by lemodizon » Fri Apr 19, 2019 1:19 am

hello everyone i'm trying to use the modal in my substack (EditStack) but when i used it the fields in my editstack are blank. here are the screenshot and below is the script for my Edit Button. where will i put the modal in my script so that i can use it. thanks

Code: Select all

 on mouseUp tbutton

global tLineToEdit

if tbutton is 1 then

put the dgHilitedLine of group "DataGridLaptopList" into tLineToEdit

if tLineToEdit is empty then
beep
Answer error "Please an item to edit. thanks" titled "R.L.M.S"

else

if tLineToEdit is a number and tLineToEdit > 0 then

## i tried to change it go to stack "EditStack" as modal but it gives me blank.
go to stack "EditStack"

set the itemDelimiter to tab

put line tLineToEdit of the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" into tData
put item 1 of tData into fld "DateField"

set the label of btn "ReasonMenu" to item 2 of tData

put item 3 of tData into fld "BadgeIDField"
put item 4 of tData into fld "FullNameField"
put item 5 of tData into fld "AssetTagField"

set the hilitedbuttonname of grp "grpChargerType" to item 6 of tData
set the hilite of btn "CheckBoxDockStation" to (item 7 of tData = "Yes")
set the hilite of btn "CheckBoxMouse" to (item 8 of tData = "Yes")
set the hilite of btn "CheckBoxKeyboard" to (item 9 of tData = "Yes")
set the hilite of btn "CheckBoxHeadset" to (item 10 of tData = "Yes")
set the hilite of btn "CheckBoxCableLock" to (item 11 of tData = "Yes")
set the hilite of btn "CheckBoxPhone" to (item 12 of tData = "Yes")
set the hilite of btn "CheckBoxMonitor" to (item 13 of tData = "Yes")

put item 14 of tData into fld "FieldSupport"
end if

end if
else
exit mouseUp
end if
end mouseUp

Attachments
Capture2.PNG
Capture1.PNG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: modal stack behavior

Post by dunbarx » Fri Apr 19, 2019 4:04 am

Hi.

So when you say your fields are empty, you mean your dataGrid is empty? Is the DG the only object on the card?

Have you refreshed your data grid recently?

Code: Select all

dispatch "ResetList" to group "yourDG"
Craig Newman

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

Re: modal stack behavior

Post by Klaus » Fri Apr 19, 2019 9:25 am

Hi Lemuel,

as I wrote on FACEBOOK, go to that modal stack as the LAST action in your script!
1. First fill all the fields etc. of the EDIT stack and
2. THEN go to that stack as modal

Code: Select all

on mouseUp tbutton
   global tLineToEdit
   
   ## I avoid nested IF THEN as much as possible.
   ## Please note how much more readable this scripts is
   if tbutton <> 1 then
      exit mouseup
   end if
   
   put the dgHilitedLine of group "DataGridLaptopList" into tLineToEdit
   if tLineToEdit is empty then
      beep
      Answer error "Please an item to edit. thanks" titled "R.L.M.S"
      exit mouseup
   end if
   
   if tLineToEdit is not a number OR tLineToEdit <= 0 then
      exit mouseup
   end if
   
   ## With this line we avoid to add ... OF CD 1 OF STACK "EditStack" to the following lines:
   set the defaultstack to "EditStack"
   ## Without this line we would get this error -> No such object...
   
   set the itemDelimiter to tab
   put line tLineToEdit of the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" into tData
   put item 1 of tData into fld "DateField"
   set the label of btn "ReasonMenu" to item 2 of tData
   put item 3 of tData into fld "BadgeIDField"
   put item 4 of tData into fld "FullNameField"
   put item 5 of tData into fld "AssetTagField"
   set the hilitedbuttonname of grp "grpChargerType" to item 6 of tData
   set the hilite of btn "CheckBoxDockStation" to (item 7 of tData = "Yes")
   set the hilite of btn "CheckBoxMouse" to (item 8 of tData = "Yes")
   set the hilite of btn "CheckBoxKeyboard" to (item 9 of tData = "Yes")
   set the hilite of btn "CheckBoxHeadset" to (item 10 of tData = "Yes")
   set the hilite of btn "CheckBoxCableLock" to (item 11 of tData = "Yes")
   set the hilite of btn "CheckBoxPhone" to (item 12 of tData = "Yes")
   set the hilite of btn "CheckBoxMonitor" to (item 13 of tData = "Yes")
   put item 14 of tData into fld "FieldSupport"
   
   ## And THEN go to that stack as MODAL
   modal stack "EditStack"
end mouseUp
Best

Klaus

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: modal stack behavior

Post by lemodizon » Sat Apr 20, 2019 1:24 pm

Klaus, still it display blank
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: modal stack behavior

Post by Klaus » Sat Apr 20, 2019 1:27 pm

Hm, I have tested my script and it worked out fine.
Please post your script again!

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: modal stack behavior

Post by lemodizon » Sun Apr 21, 2019 8:43 am

Klaus, this is the revised script code from the edit button.

Code: Select all


on mouseUp tMouseButton
   global tLineToEdit
   
   if tMouseButton <> 1 then
      exit mouseUp
   end if
   
   put the dgHilitedLine of group "DataGridLaptopList" into tLineToEdit
   
   if tLineToEdit is empty then
      beep
      Answer error "Please an item to edit. thanks" titled "R.L.M.S"
      exit mouseUp
   end if
   
   
   if tLineToEdit is not a number or tLineToEdit <= 0 then
      exit mouseUp
   end if 
   
   set the defaultstack to "EditStack"
   
   set the itemDelimiter to tab
   
   put line tLineToEdit of the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" into tData
   put item 1 of tData into fld "DateField"
   
   set the label of btn "ReasonMenu" to item 2 of tData
   
   put item 3 of tData into fld "BadgeIDField"
   put item 4 of tData into fld "FullNameField"
   put item 5 of tData into fld "AssetTagField"
   
   set the hilitedbuttonname of grp "grpChargerType" to item 6 of tData
   set the hilite of btn "CheckBoxDockStation" to (item 7 of tData = "Yes")
   set the hilite of btn "CheckBoxMouse" to (item 8 of tData = "Yes")
   set the hilite of btn "CheckBoxKeyboard" to (item 9 of tData = "Yes")
   set the hilite of btn "CheckBoxHeadset" to (item 10 of tData = "Yes")
   set the hilite of btn "CheckBoxCableLock" to (item 11 of tData = "Yes")
   set the hilite of btn "CheckBoxPhone" to (item 12 of tData = "Yes")
   set the hilite of btn "CheckBoxMonitor" to (item 13 of tData = "Yes")
   
   put item 14 of tData into fld "FieldSupport"
   modal stack "EditStack"
   
end mouseUp



Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: modal stack behavior

Post by Klaus » Sun Apr 21, 2019 1:52 pm

Hm, script is OK...
Do you get an error, or just an "empty" EditStack?

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: modal stack behavior

Post by lemodizon » Sun Apr 21, 2019 3:35 pm

Klaus,
no error at all, just all the fields are empty and the stack "EditStack" is already in modal.
Attachments
edit.PNG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: modal stack behavior

Post by Klaus » Sun Apr 21, 2019 3:55 pm

Sorry, no brilliant idea in the moment, I can offer to take a look at the stack, if you like.
If yes, zip it and send it to: klaus AT major-k.de

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: modal stack behavior

Post by lemodizon » Mon Apr 22, 2019 6:07 am

Klaus, i already send it to your email thank you very much for checking on it.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: modal stack behavior

Post by Klaus » Mon Apr 22, 2019 10:39 am

You have THIS in the script of your EDITSTACK:

Code: Select all

on preopenstack
   put empty into fld "DateField"
   set the label of btn "ReasonMenu" to empty
   put empty into fld "BadgeIDField"
   put empty into fld "FullNameField"
   put empty into fld "AssetTagField"
   set the hilitedbutton of grp "grpChargerType" to 0
   set the hilitedbutton of grp "grpLaptopAccessories" to 0
   put empty into fld "FieldSupport"
end preopenstack
Still surprised that your fields etc. are empty?
You need to adjust your actions, the above script is only neccessary when the user clicks "ADD"!

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: modal stack behavior

Post by lemodizon » Mon Apr 22, 2019 5:04 pm

Sorry klaus i just copied the stack of addstack and i forgot to remove the script on the sub stack of editstack. this is now working thank u very much. i have a question regarding find/search is this possible i want to find/search only in the column of my datagrid under asset tag column section only? i tried this script code below. it search all the data in my data grid. and when it found the data it will display the found data but i don't know how to retrieve the data that was entered before. or do i have to create a button for reset to retrieve the previous data were entered/stored. thanks in advance

Code: Select all

on mouseUp tbutton
  
  if tbutton is 1 then
    
    ask "Please enter the asset tag of the laptop"
    
    put it into tSearchString
    put the dgtext of grp "DataGridLaptopList"of cd "RLMS-cd1"  of stack "RLMS" into tOldData
    
    filter tOldData with ("*" & tSearchString & "*")
    
    
    if tOldData = empty then
      beep
      answer "no data found!"
      exit to top
    else
      
      ## We found something, so lets display the results:
      set the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to tOldData
      set the dghilitedlines of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to (the num of lines of tOldData)
    end if
    
  else
    
    exit mouseUp
    
  end if
  
end mouseUp
Attachments
Capture.PNG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: modal stack behavior

Post by Klaus » Mon Apr 22, 2019 6:42 pm

Hi Lemuel,

with FILTERing the complete data, the search string can also be found in other columns,
so just use the build-in FINDLINE (or FINDINDEX) command:

Code: Select all

on mouseUp tbutton
   
   if tbutton <> 1 then
      exit mouseup
   end if
   
   ask "Please enter the asset tag of the laptop"    
   put it into tSearchString
   
   ## We let the datagrid library do the work and pass the name of the column 
   ## ("asset"? Replace with your name!) we want to be searched and the searchstring:
   dispatch "FindLine" to grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" with "asset", tSearchString
   
   ## Now we check THE RESULT, if it = 0, then nothing is found otherwise it holds the number of the line 
   ## in the datagrid and you can do whatever you want with that information:
   put the result into tLineNumber
   if tLineNumber = 0 then
      answer "Nothing found!"
   else
      answer "Found in line" && tLineNumber && "of the datagrid!"
   end if
end mouseup
Please download the Datagrid PDF docs here: http://lessons.livecode.com/m/datagrid
Under the TOPICS on the left side, the tiny link.

Read it carefully about 12 times (at least) and then work through all examples.
I did and do this every time I need to seriously work with datagrids, really!


Best

Klaus

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: modal stack behavior

Post by lemodizon » Wed Apr 24, 2019 11:08 am

Thanks Klaus, this is now working :)
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”