I am developing the the front end to a database that accesses more than 3000 documents that begin in 1950 and continue to the present year, named in the following format:
item 1: the last two digits of the year of publication and the order of publication in that year as a four-digit number, e.g., 14-1004
item 2: the acronym of the agency to whom the document is addressed, e.g., DRT
item 3: the subject of the document
Example of full name: 14-1104 DRT Gross Receipts Tax
Example correct ascending order:
55-1111 DOA Claim for Damage
88-2233 DPS Vehicle Accident
00-4441 DRT License Fees
14-7878 CQA Inspection Fees
I have entered the data into a three-column datagrid table. I want the order to be chronologically correct, but the default ascending sort puts the list as follows: "00-" up to "17-" and then "50-" and so on up to "99-". I want the correct chronological order, both ascending and descending.
Since I can't change the naming convention, can a script be written that accomplishes this? I'm not asking for anyone to write it, but need to abandon the use of the datagrid if it is probably or clearly not possible. If it is possible, I'll will work on it until I discover how. Thank you for your suggestions.
Monty
Sorting a Datagrid Column
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 366
- Joined: Mon Jun 10, 2013 1:32 pm
Re: Sorting a Datagrid Column
Hi,
Simplest way I can think of as I have used it more than ones in a table field is add an extra column at the end
by extracting the 4 digits after the "year-" of item 1 and put it into that column and sort on that column.
In your grid make the column have a 0 or 1 width or somehow
make sure it can't be seen - or if it doesn't matter make it the visible first column.
There are many ways of implementing the method using arrays, strings/lines in listboxes or tables and copying to or from the output - iv'e probably used every one
depending on the size of data and deadlines - usually the latter
Regards Lagi
Simplest way I can think of as I have used it more than ones in a table field is add an extra column at the end
by extracting the 4 digits after the "year-" of item 1 and put it into that column and sort on that column.
In your grid make the column have a 0 or 1 width or somehow
make sure it can't be seen - or if it doesn't matter make it the visible first column.
There are many ways of implementing the method using arrays, strings/lines in listboxes or tables and copying to or from the output - iv'e probably used every one
depending on the size of data and deadlines - usually the latter

Regards Lagi
Re: Sorting a Datagrid Column
Hi Monty,montymay wrote: 55-1111 DOA Claim for Damage
88-2233 DPS Vehicle Accident
00-4441 DRT License Fees
14-7878 CQA Inspection Fees
I have never worked with datagrids, but I assume we
can use the sort command... If this is true then you
could do something like:
Code: Select all
-- T contains your data above
sort lines of T ascending numeric by criteria( char 1 to 2 of each)
Code: Select all
function criteria yy
if yy > 50 then return yy - 50
else return yy + 50
end criteria
it's easy to add the 4 next digits to the whole sort.
HTH,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!