cancel
Showing results for 
Search instead for 
Did you mean: 

Sort data in matrix using DBDataSources

Former Member
0 Kudos

Hi,

I have a UserTabele and I want read data from the table to a matrix. It's no problem. But how I can sort data when I use DBDataSource.DoQuery( Condition )? I want use something like "order by" in SQL, but data are getting

according by filed 'Code'. Any suggestions?

Regards

Tomasz Tura

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

does anybody have the "CODE"....for sorting the userdatasource???

0 Kudos

A new part that makes me laugh about the API.

Strange days where sw-developers have to write many dozents lines of code just to sort a simple Matrix.

It´s hard to explain these costs to our deer customers...

Former Member
0 Kudos

ha !

you are right on target with this comment ... been over a year since you made it and still applies!

Former Member
0 Kudos

Below is an outline of a technique I used to add sorting to an existing add-on screen that had been written a long time ago using DBDataSources. Although not particularly efficient, the biggest advantage of this technique is that hardly any of the existing code was changed avoiding a lot of extra testing.

Original code was along the lines of

- Set up DBDataSource Conditions
- DBDataSource.Query
- for counter = 0 to (DBDataSource.Size - 1)
-    Set offset on DBDataSource to loop counter
-    Set some values to UserDataSources
-    Matrix.Addrow
- next

I simply introduced a 2 dimensional array to the above, writing the offset and the sort field from the DBDataSource to it. Performed a Quicksort on the array, and then changed the "Set offset on DBDataSource to loop counter", to instead use the pick up the appropriate offset from the sorted array.

New code is along the lines of

- Set up DBDataSource Conditions
- DBDataSource.Query
- **Populate Array & Quicksort it**
- for counter = 0 to (DBDataSource.Size - 1)
-    Set offset on DBDataSource to **offset from Array**
-    Set some values to UserDataSources
-    Matrix.Addrow
- next

(NB. The actual code has lots of calculations and additional rules filtering the data so is a bit too complex to easily illustrate the technique)

John.

Former Member
0 Kudos

Hi

I also need such a functionality.

Have you already found a solution?

Or anyone else?

Kind regards

Iris

AlexGrebennikov
Active Contributor
0 Kudos

I suppose you can try to use DI-RecordSet to execute your own query and just fill in matrix in loop row by row..

Of couse it will be too slow, but...

I hope, it helps.