Re: how to detect a certain date in a dg table column
Posted: Wed Sep 13, 2023 1:04 pm
Sorry Stam, I wrote before I read your piece. I'll try it now..
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
???
Code: Select all
...
## NOW check if we had found something and take action if yes:
if tFound = TRUE then
## tKey = the INDEX of the array with the found date
set the dghilitedIndexes of grp "your dg here..." to tKey
## tCompleteRow is an array with the content of the found row
## do your thing
end if
...You are experienced enough to point out if I have made an error in my syntax, I'm not seeing it although I did write this off the top of my head and there may be a typo or some silly error. However, vague insinuations don't help.
Code: Select all
command hiliteRow pFilter, pColumn, pDataGrid
# pFilter = text to search for, pColumn is the column to search in
# pDataGrid = the _LONG ID_ of the datagrid to search
local tArray, tKeys
put the dgData of pDataGrid into tArray
filter elements of tArray where each[pColumn] = pFilter
if tArray is empty then
set the dgHilitedIndexes of pDataGrid to empty
exit hiliteRow
end if
put replaceText(the keys of tArray, "\R", comma) into tKeys // "\R" is regex for CR, LF or CRLF
set the dgHilitedIndexes of pDataGrid to tKeys
end hiliteRowCode: Select all
hiliteRow <the text to search for>, <column name>, <the long id of the datagrid to search>Code: Select all
hiliteRow the long date, "reviewDate", the long id of group "datagrid 1"Code: Select all
filter elements of tArray where each[pColumn] = pFilter
Code: Select all
filter elements of tArray where each[pColumn] contains pFilterCode: Select all
if the dgtext of grp "Datagrid 1" of cd "custlist" contains the long system date then
put the dgdata of grp "datagrid 1" of cd "custlist" into tData
put the keys of tData into tKeys
put the long system date into tDate
repeat for each line tKey in tKeys
if tData[tKey]["ReviewDate"] = tDate then
put tData[tKey]["Name of customer"] into fld "fbizname"
put tData[tKey]["Lastinvoice"] into fld "flastinvoice"
exit repeat
end if
end repeat
end if