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!
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
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
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
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
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
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"!
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
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
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
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!