How to order form grid by field that is not included in the data source

So this can be done by updating a query method init of the data source on which grid is based:


 QueryBuildDataSource qbds;
 QueryBuildDataSource qbds2;
 QueryBuildDataSource qbdsn;

//original data source
qbds = DataSource_ds.query().dataSourceTable(tableNum(DataSourceTable));

 qbds2 = qbds.addDataSource(tableNum(OtherTable));
 qbdsn = qbdsn-1.addDataSource(tableNum(OtherTableN));
 qbdsn.addSortField(fieldNum(OtherTableN, FieldYouWantToSortOn));

Manually order record in the form grid

You know those kind of forms where you can use buttons to order records in the right position?

It is quite easy to replicate. It won’t work for all solutions though,

Example of the standard code is a WHSLocDirTable form.

To implement this solution you would have to make changes to the source table ( Add additional field, index, field group , methods for update , insert and delete, as well as moving logic,)

add changes to the the form ( additional field, buttons for up and down and related code, as well as make changes to init method of the form ( to sort by position) and some changes that will have to be implemented on the data source. )