cancel
Showing results for 
Search instead for 
Did you mean: 

Control sort order of UDO Child

Former Member
0 Kudos

Hey All,

Can anyone tell me how I can control the display order of a document UDO lines matrix? We have document lines created that have a date in the data and the client would like the data to display with the newest entries on top.

Anyone know how I can do this?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Any ideas or is this just not possible? can I maybe use the conditions object to do this somehow?

Former Member
0 Kudos

One way would be to base your Matrix on UserDataSources. You could populate these in whatever order you wanted and display them on screen by manually using matrix.addrow. Intercepting the MATRIX_LOAD event should let you display them when the UDO is displayed, and the DATASOURCE_LOAD event should let you copy everything back into the DBDataSource before it is committed to the database.

Its not very efficient, but should work.

John.

Former Member
0 Kudos

Thanks John,

This would be a huge amount of work at this point as I have already coded the entire application to use the DBDatasources from Business One.

Do you know if I can query the DB Datasource after Business One has loaded it with data to reorder it using a conditions object or something like that?

Former Member
0 Kudos

I can see one possibility, but I have never tried it on a UDO screen. Basically I am thinking you might be able to use a variation on a technique I described previously for adding sorting into a DBDatasource based screen

Theoretically this might work for your UDO although you would also need to handle the fact that the UDO itself will be attempting to auto-populate the matrix whereas in my previous posting the matrix population was always under user control. (Either matrix.clear or set bubbleevent = false might handle this additional complexity)

I think you could probably end up with something like the following

- Intercept MATRIX_LOAD event
- ??matrix.Clear??
- **Populate Array from dbdatasource & Quicksort it**
- for counter = 0 to (DBDataSource.Size - 1)
-    Set offset on DBDataSource to **offset from Array**
-    Matrix.Addrow
- next
- ??BubbleEvent = false??

I have never tried it so it might not work out when it comes to updating, but on the plus side it should be pretty quick to add into an existing screen to test.

One final thought - For a <b>really</b> quick test to see if it is likely to work before going to the trouble of introducing the array & proper sorting routine, simply loop through the dbdatasource from last record down to first record and see if everything still works with the rows displayed in reverse order.

eg.

- Intercept MATRIX_LOAD event
- ??matrix.Clear??
- for (DBDataSource.Size - 1) to Counter Step -1
-    Set offset on DBDataSource to counter
-    Matrix.Addrow
- next
- ??BubbleEvent = false??

Hope it works out,

John.

Former Member
0 Kudos

Thanks for the great post and help John. Some great ideas there. I have tried to do this using the Matrix Load event and it seems to work fine for just browsing the records. But if you try to add new records or update existing ones it seems to cause problems.

I will keep researching this to see if I can find another way.

Thanks once again I really appreciate your help with something as different as this.