Hi kamran,
question: Is your datagrid of type FORM? This is mandatory for this purpose!
And be warned, this is no beginners stuff!
Ok, here is what you will need, beware, this is out of my head
1. You also need to leave a "slot" for the values (TRUE or FALSE) of the checkbox in the DGData!
I guess the "initial" values of these checkboxes will be -> UNchecked
If that is the case then you do:
Code: Select all
command fillDataGrid x
switch x
case 1
put "Sub Module of Main Module 1" into field "Field_sub"
put "Unit1 of Sub module1" into theDataA[1]["Unit"]
put "Unit2 of Sub module1" into theDataA[2]["Unit"]
put "Unit3 of Sub module1" into theDataA[3]["Unit"]
put FALSE into theDataA[1]["CheckBox_Value"]
put FALSE into theDataA[2]["CheckBox_Value"]
put FALSE into theDataA[3]["CheckBox_Value"]
set the dgData of group "DataGrid 1" to theDataA
## Same for you other CASE conditions!
...
2. Add a script to the checkbox in your TEMPLATE group of the datagrid.
This will add the new value of the checkbox into the DGdata:
Code: Select all
on mouseup
put the dgindex of me into tIndex
put the dgDataOfIndex[tIndex] of grp "Datagrid 1" into tData
## Write the hilite to the DGData!
put the hilite of me into tData["CheckBox_Value"]
set the dgdataOfIndex[tIndex] of grp "Datagrid 1" to tData
end mouseup
3. You need to add some line to the "on fillindata" in the datagrid "row behavior":
Code: Select all
on fillindata tDataArray
## 1. Fill your field with text:
set the text of fld "name of your field here" to tDataArray["Unit"]
## Set hilite of checkbox:
set the hilite of btn "checkbox" of me to tDataArray["Checkbox_Value"]
end fillindata
After this has been done and working, you can loop through the DGData and check all keys-> ["Checkbox_Value"]:
Code: Select all
...
put the dgData of grp "Datagrid 1" into tData
repeat for each key tKey in tData
if tData[tKey]["Checkbox_Value"] = TRUE then
put tData[tKey]["Unit"] into theUnit
## Update database now! :-)
Well, that's it basically
Best
Klaus