Page 1 of 1

Sorting a Datagrid Column

Posted: Mon Feb 27, 2017 11:47 am
by montymay
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

Re: Sorting a Datagrid Column

Posted: Mon Feb 27, 2017 1:26 pm
by Lagi Pittas
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

Re: Sorting a Datagrid Column

Posted: Mon Feb 27, 2017 3:11 pm
by Thierry
montymay wrote: 55-1111 DOA Claim for Damage
88-2233 DPS Vehicle Accident
00-4441 DRT License Fees
14-7878 CQA Inspection Fees
Hi Monty,

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
if this works with datagrid,
it's easy to add the 4 next digits to the whole sort.

HTH,

Thierry