Data Grid - how to check per column

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

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

Data Grid - how to check per column

Post by lemodizon » Sat Sep 07, 2019 12:07 pm

Hi Everyone,

How can i check in the column of data grid the (Birthdate) and update (Age). see the below example.

Thanks in advance.
Attachments
Capture33.PNG

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

Re: Data Grid - how to check per column

Post by dunbarx » Sat Sep 07, 2019 2:18 pm

What Klaus suggested, and the way I always deal with getting data into and out of a dataGrid, is to extract the entirety of the contents of the DG and then use good ol' LiveCode do its work.

You extract either with the "DGData", with yields an array, or my preference usually, the "DGText" which yields ordinary, er, text.

Once you have that, the DGText, say, you can use delimiters to manipulate the data. Tabs and returns are the usual suspects.

So just as if you were trying to dissect the contents of an Excel spreadsheet, each row is delimited by a return, and each "cell" is delimted by a tab. A repeat loop gets it all and orders it to your liking.

Craig

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

Re: Data Grid - how to check per column

Post by lemodizon » Thu Sep 12, 2019 4:40 pm

Hi Craig,

Thanks for the information. i was having a hard time in exploring data grid of livecode. Thanks for the support of this forum.

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

Re: Data Grid - how to check per column

Post by lemodizon » Thu Sep 12, 2019 5:10 pm

SqliteDb.PNG
Hi everyone,

I'm still exploring the data grid of livecode. i created a sqlite database see picture above. where i click the button check age it will automatic update the age. my problem is how can i put the updated age to my sqlite database per column. excuse me in my coding if you find it messy.

Thanks in advance.

Code: Select all

////here is the code in my checkage button
on mouseUp
   put the dgText of grp "StudentList" into tData
   set itemdel to TAB
   
   repeat for each line tLine in tData
      put item 5 of tLine into tDate
      put age(tDate) into tAge
      put  item 1 of tLine  & tab & item 2 of tLine  & tab&  item 3 of tLine  & tab&  item 4 of tLine  & tab & tDate & Tab &tAge & cr after tNewList
      
   end repeat
   
   if  item 1 of tLine is not empty then
      UpdateStudentInfo item 1 of tLine,  tAge
   else
      exit top
   end if
      
   delete char -1 of tNewList
   set the dgtext of grp "StudentList" to tNewList
end mouseUp

Code: Select all

////here is the command to update in the database

[img][/img]
command UpdateStudent pStudentID,pStudentAge
   local tSQLStatement
   global sDatabaseID
   
   repeat with y = 1 to the number of lines of tData
      put "UPDATE MyStudents SET  Age = '"&pStudentAge&"' WHERE ID = '"&pStudentID&"' " into tSQLStatement
      revExecuteSQL sDatabaseID, tSQLStatement
      
   end repeat
   
   if the result is an integer then
      answer "Age successfully UPDATED!"
   else
      answer "Sorry, there was a problem in UPDATING the information"
   end if
end UpdateStudent


Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”