Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How to make grid list's cursor on the 1st row

(0) ShareShare
ReportReport
Posted on by

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,

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: How to make grid list's cursor on the 1st row

    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).

    learn.microsoft.com/.../form-data-source-properties

  • Anton Venter Profile Picture
    Anton Venter 19,495 Super User 2025 Season 1 on at
    RE: How to make grid list's cursor on the 1st row

    You can use the positionToRecord() datasource method passing the buffer of the record you want to be selected.

  • VoltesDev Profile Picture
    VoltesDev on at
    RE: How to make grid list's cursor on the 1st row

    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

  • Verified answer
    Anton Venter Profile Picture
    Anton Venter 19,495 Super User 2025 Season 1 on at
    RE: How to make grid list's cursor on the 1st row

    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);
            }
        }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans