Page 1 of 2
How to insert a multiple data in datagrid
Posted: Tue Mar 26, 2019 12:00 pm
by lemodizon
Hello everyone
just want to ask on how to insert multiple data in a certain column when it is checked in the check boxes. thanks below is the script code in the save button. thanks in advance everyone
Code: Select all
on mouseUp
## this script is for radio buttons
put the hilitedbutton of grp "ChargerType" into tselected
put the label of btn tselected of grp "ChargerType" into tselectedName
put fld "DateField" & TAB & fld "UserNameField" & TAB & fld "AssetTagField" & TAB & tselectedName into tNewInputData
## Check if datagrid already has content:
put the dgtext of grp "LaptopDataGrid"of cd "AssetCard" of stack "ITWC" into tOldData
## New and first entry:
if tOldData = EMPTY then
put tNewInputData into tOldData
else
## We ADD the data
put CR & tNewInputData after tOldData
end if
## Now set the new data:
set the dgtext of grp "LaptopDataGrid" of cd "AssetCard" of stack "ITWC" to tOldData
end mouseUp
Re: How to insert a multiple data in datagrid
Posted: Tue Mar 26, 2019 12:15 pm
by bogs
Heya lemodizon,
I don't think you can do it the way your imagining (least according to that picture). I think you'd have to have a separate table for laptop accessories, with columns for each item, then use a join to pull it.
I know I am saying that badly, but the BYU course has a good example of it in the
310 section, where they are talking about foreign keys and relational dbs.
In a relational data model, instead of putting all of the information into a single huge table, the data instead is grouped into smaller tables, each of which describes a single type of object or entity. For example, for Acme Co. we might have one data table for employees, another one for departments, and a third for projects.

- It is relational, baby...
Re: How to insert a multiple data in datagrid
Posted: Tue Mar 26, 2019 1:57 pm
by dunbarx
Hi.
What Bogs said.
Broadly, the dataGrid is a two dimensional "array" of data. If you use the "dgText", you have to think of that as tab and return delimited, sort of like a spreadsheet.
So if you extract the contents of the DG with the dgText, whatever you do to that dataset has to be formatted accordingly. To work entirely within a single "column" means to work entirely within a certain item of each line.
Do you see? if your dgText looked like this:
A B C
D E F
G H I
there would be tabs separating, say, "A" from "B". In order to work within a single column, you would (pseudo):
Code: Select all
set the itemDel to tab
repeat with y = 1 to the number of lines of yourDGText
put y into item 2 of line y of yourDGText
end repeat
And you would end up with:
A 1 C
D 2 F
G 3 I
and then you could set the dgText of the DG to that.
Craig Newman
Re: How to insert a multiple data in datagrid
Posted: Wed Mar 27, 2019 2:37 pm
by lemodizon
Thank you Bogs and Craig
i just revised my data grid into spreadsheet style since i'm still studying the data grid.
just want to ask on how to delete on hilited line in the datagrid and what is the function of the Edit behavior script on the datagrid.are they the same with edit script? thanks in advance
Re: How to insert a multiple data in datagrid
Posted: Wed Mar 27, 2019 3:30 pm
by bogs
I wonder if 'selectedChunk' or 'selectedText' would work in that instance?
(* Disclaimer, I don't do much with DataGrids).
Alternately, from dg specific things, you might crack open the dictionary and look up -
DeleteLine
dgDataOfLine
dgHilitedLines
dgIndexOfLine
...etc.
Re: How to insert a multiple data in datagrid
Posted: Wed Mar 27, 2019 3:33 pm
by Klaus
Check my answer on FACEBOOK.
Re: How to insert a multiple data in datagrid
Posted: Thu Mar 28, 2019 4:22 am
by lemodizon
Thank you very much Bogs and Klaus

Re: How to insert a multiple data in datagrid
Posted: Thu Mar 28, 2019 11:40 am
by lemodizon
Hello everyone,
i was able to delete per line using the dghilitedline and then dispatch thanks again.
i'm in the edit button i don't know on how to put the item via checkbox and radio button
thanks for the help i really appreciate it. thanks in advance
Code: Select all
## this is my edit button script
on mouseUp
put the dgHilitedLine of group "LaptopDataGrid" into tLineToEdit
if tLineToEdit is a number and tLineToEdit > 0 then
go to stack "LAPTOPINFO"
set the label of btn "SaveButton" to "Save Changes"
set the itemDelimiter to tab
put line tLineToEdit of the dgtext of grp "LaptopDataGrid"of cd "AssetCard" of stack "ITWC" into tData
put item 1 of tData into fld "DateField"
put item 2 of tData into fld "UserNameField"
put item 3 of tData into fld "AssetTagField"
put item 11 of tData into fld "CheckbyField"
end if
end mouseUp
Re: How to insert a multiple data in datagrid
Posted: Thu Mar 28, 2019 1:17 pm
by Klaus
As I answered on FACEBOOK:
####################################
Do you mean how to make your checkboxes reflect the YES/NO form the datagrid?
Then Mr. Boole is your friend!

...
set the hilite of btn "Dock Station" to (item 5 of tData = "Yes")
set the hilite of btn "Mouse" to (item 6 of tData = "Yes")
## etc..
...
The engine will first resolve everything inside of the parenthesis,
and this will resolve to TRUE or FALSE in your example.
Even if the items are empty!
You get the picture...
#######################################
Re: How to insert a multiple data in datagrid
Posted: Thu Mar 28, 2019 2:06 pm
by lemodizon
Thanks Klaus and to Mr. Boole

Re: How to insert a multiple data in datagrid
Posted: Sat Mar 30, 2019 3:47 am
by lemodizon
Hello everyone
i'm confused in the edit button especially in the radio button hope you can help me thanks in advance
https://www.dropbox.com/s/zj32v11f40ky ... code?dl=0
Re: How to insert a multiple data in datagrid
Posted: Sat Mar 30, 2019 9:53 am
by Klaus
Hi Lemuel,
see Facebook!
I think you are making it more complicated than is is!
With radiobuttons in a group, we do NOT save the hilite of each button, we save the NUMBER or NAME of the hilitedbutton in that group. When setting this back later, LC knows that only THAT button is hilited in that group and all the other buttons are not.
Example:
We have a group of 2 radiobuttons -> Yes and No
We click Yes, then:
-> the hilitedbutton of grp "my radios" = 1
-> the hilitedbuttonname of grp "my radios" = Yes
So to "restore" the hilite in that radiobutton group, we can set the NUMBER or NAME of the button that we want to be hilited:
...
set the hilitedbutton of grp "my radios" to 1
...
OR
...
set the hilitedbuttonname of grp "my radios" to "Yes"
...
In both cases LC will hilite htat namely button and unhilite all the other button in that group.
That is the big difference to checkboxes.
Best
Klaus
Re: How to insert a multiple data in datagrid
Posted: Mon Apr 01, 2019 12:24 pm
by lemodizon
Thanks Klaus, This is now working... i'm still working when i save it duplicates instead it remains. thanks klaus again.
Re: How to insert a multiple data in datagrid
Posted: Wed Apr 03, 2019 1:28 pm
by lemodizon
hello everyone i'm in edit button script but when i tried to click save it delete the first line of the data grid. thanks in advance.
Code: Select all
on mouseUp
if the hilite of btn "DockStationCheck" then
put "Yes" into tcheckDockStation
else
Put "No" into tcheckDockStation
end if
if the hilite of btn "MouseCheck" then
put "Yes" into tcheckMouseCheck
else
Put "No" into tcheckMouseCheck
end if
if the hilite of btn "HeadsetCheck" then
put "Yes" into tcheckHeadsetCheck
else
Put "No" into tcheckHeadsetCheck
end if
if the hilite of btn "CableLockCheck" then
put "Yes" into tcheckCableLockCheck
else
Put "No" into tcheckCableLockCheck
end if
if the hilite of btn "PhoneCheck" then
put "Yes" into tcheckPhoneCheck
else
Put "No" into tcheckPhoneCheck
end if
if the hilite of btn "ExternalMonitorCheck" then
put "Yes" into tcheckExternalMonitorCheck
else
Put "No" into tcheckExternalMonitorCheck
end if
//----------------------------------------------------------------
put fld "DateField" & TAB & fld "UserNameField" & TAB & fld "AssetTagField" & TAB & the hilitedbuttonname of grp "ChargerType" & TAB & tcheckDockStation & TAB & tcheckMouseCheck & TAB & tcheckHeadsetCheck & TAB & tcheckCableLockCheck & TAB & tcheckPhoneCheck & TAB & tcheckExternalMonitorCheck & TAB & fld "CheckbyField" into tNewInputData
put tNewInputData into tOldData
// when i set this it delete the first line in the data grid
set the dgtext of grp "LaptopDataGrid" of cd "AssetCard" of stack "ITWC" to tOldData
end mouseUp
Re: How to insert a multiple data in datagrid
Posted: Wed Apr 03, 2019 2:37 pm
by Klaus
Hi Lemuel,
you do not check if there are already data in your datagrid, so you overwrite the first (and oviously only) line every time! Do this:
Code: Select all
...
put fld "DateField" & TAB & fld "UserNameField" & TAB & fld "AssetTagField" & TAB & the hilitedbuttonname of grp "ChargerType" & TAB & tcheckDockStation & TAB & tcheckMouseCheck & TAB & tcheckHeadsetCheck & TAB & tcheckCableLockCheck & TAB & tcheckPhoneCheck & TAB & tcheckExternalMonitorCheck & TAB & fld "CheckbyField" into tNewInputData
put the dgtext of grp "LaptopDataGrid" of cd "AssetCard" of stack "ITWC" intotOldData
## Check here and APPEND new data if neccessary!
if tOldData = EMPTY then
put tNewInputData into tOldData
else
put CR & tNewInputData AFTER tOldData
end if
set the dgtext of grp "LaptopDataGrid" of cd "AssetCard" of stack "ITWC" to tOldData
end mouseUp
Best
Klaus