Hi guys,
I'm creating a form displaying a grid list. The normal display will be as the initial index table, so will be in ascending order. I would then make it Descending and save it as NewView. Question is what is the best way to make the cursor will automatically placed on the 1st row ? (which mean by the descending order of my saved view, will be the latest/biggest index number)
Should I do it programmatically in X++, where and how ?
Thanks,
Hi, You can check StartPosition Property of Form Root DataSource. It determines whether the first or the last record should be the current one when the form opens.
If the property is set to First, even if user change the form to Descending based on a field and create a Saved view. On opening the view, it should be first record opened (As per applied sorting on field).
You can use the positionToRecord() datasource method passing the buffer of the record you want to be selected.
Hi Anton,
Thanks so much. Just for learning, may I know also if there is a way on the UI side? I mean can the UI front-end also cater this ? since I found many people using this SaveAs View for their own personalize, when they change the column to be descending, it will display as descending but the row will point to the 1st record way down if we have a lots of record.
Thanks
You can change the sorting in the init() method of the datasource in question, see my example below. The selected row is now at the top of the grid, the first row.
[DataSource] class CustTable { public void init() { super(); QueryBuildDataSource qbds = this.query().dataSourceNo(1); qbds.clearSortIndex(); qbds.addSortField(fieldNum(CustTable, AccountNum), SortOrder::Descending); } }
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156