• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LiveCloud arrays and Datagrid
#13
Code:
on mouseUp
  local tKeys, tOutputA, tCount, tDataA
 
  //CLEAR datagrid
  set the dgData of group "datagrid" to empty
 
  //GET ALL THE KEYS OF THE TABLE
  put cdb_tableKeys("testTable") into tKeys
 
  //GET ALL RECORDS OF THE TABLE
  put cdb_read("testTable", "*", "cloud") into tOutputA
 
  put 0 into tCount
  //REPEAT FOR EVERY RECORD SO WE CAN CREATE AN ARRAY FORMATTED FOR datagrid
  repeat for each key xRecordID in tOutputA
     add 1 to tCount
     
     //GRAB THE RECORDID SO WE CAN DISPLAY IT
     put xRecordID into tDataA[tCount]["recordID"]
     
     //REPEAT FOR EVERY KEY IN THE TABLE SO WE CAN DISPLAY ALL COLUMNS OF THE RECORDS
     repeat for each item xKeyName in tKeys
        put tOutputA[xRecordID][xKeyName] into tDataA[tCount][xKeyName]
     end repeat
  end repeat
 
  //POPULATE datagrid
  set the dgData of group "datagrid" to tDataA
end mouseUp

I added comments to the code. I hope it's easier to understand. Let me know if you have any questions.

For your case, place the code in the preOpenCard. If your expense table only has the two keys expenseName and expenseAmount then you shouldn't need to modify the code. If you have more keys but only want to display those two then replace:

put cdb_tableKeys("testTable") into tKeys

with

put "expenseName,expenseAmount" into tKeys

If you don't want to display the recordID remove or comment out:

put xRecordID into tDataA[tCount]["recordID"]
  Reply


Messages In This Thread
LiveCloud arrays and Datagrid - by Bizbuzz - 11-21-2019, 11:01 AM
RE: LiveCloud arrays and Datagrid - by efrain.c - 11-21-2019, 07:03 PM
RE: LiveCloud arrays and Datagrid - by Papa Cann - 02-23-2020, 03:47 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 02-24-2020, 06:26 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-14-2019, 11:27 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-16-2019, 09:31 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 12-17-2019, 02:14 AM
RE: LiveCloud arrays and Datagrid - by sid - 12-17-2019, 09:54 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-18-2019, 10:20 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-19-2019, 10:12 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-14-2020, 02:56 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 02-14-2020, 08:47 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-15-2020, 07:52 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-24-2020, 07:52 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 02-24-2020, 09:17 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-24-2020, 09:39 PM
RE: LiveCloud arrays and Datagrid - by sid - 06-26-2020, 11:34 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)