web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

(0) ShareShare
ReportReport
Posted on by 15

Hi All,

I have a FormControlGrid with multiple columns on it that has a specifically defined sort order set in the init() method, and I would like to disable user sorting of columns. I don't want to disable the grid since I'd like users to be able to click fields in the grid to navigate to different parts of Dynamics via the grid, but even that doesn't disable their ability to change the sort order. 

I've tried overriding the sort() method on a column in the [ClassName extends FormRun] per this post (thank you, Martin), but it doesn't seem to have any effect. What am I missing here? Putting a breakpoint on the String class never gets hit. Do I need to somehow call that class? Isn't it being automatically intialized?

[Control("String")]
class DATASOURCENAME_CONTROL
{
/// <summary>
///
/// </summary>
/// <param name = "_sortDirection"></param>
/// <returns></returns>
public int sort(SortOrder _sortDirection)
{
int ret;

//ret = super(_sortDirection); //COMMENT OUT SUPER

return ret; // <--BREAKPOINT
}

}

Any help would be greatly appreciated.

Edit: If it's helpful, the datasource on the form is a View and the View uses a query as a datasource.

I have the same question (0)
  • Martin Dráb Profile Picture
    236,972 Most Valuable Professional on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Hmm, it seems that meddling with sort() indeed doesn't work anymore. Most likely it's because we now have a new grid control and it works differently in some respects.

    An ideal solution for your problem would be removing the option to choose sort direction (e.g. Sort A to Z) . Unfortunately I don't know how to do it. But if you want, you can ignore sorting by removing the sort field from the query.

    For example:

    public void executeQuery()
    {
        QueryBuildDataSource qbds = this.queryRunQueryBuildDataSource();
        if (qbds)
        {
            for (int i = 1; i <= qbds.sortFieldCount(); i  )
            {
                qbds.removeOrderByField(qbds.sortField(i));
            }
        }
    
        super();
    }

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Hi Dynamics-user-185,

    Another workaround will be using form personalization.

    On the form right click on the control  >> Select Freeze column >> It will freeze the column and it will not allow you to filter the fields. - Try this as workaround - If it works you can make use of it.

    After freezing column you can the save the view as personalization and you can apply that personalization across all users.

    Also you cannot filter the fields if you are using this

    Thanks,

    Girish S.

  • Dynamics-user-185 Profile Picture
    15 on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Interesting, is the executeQuery() call an override in the form or on the datasource? I'll give this a shot in the next day or two. Yeah ideally it'd get hidden but as long as the sort is disabled I guess that's what matters.

  • Dynamics-user-185 Profile Picture
    15 on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Do you mean freezing the column in Dynamics/the sandbox, or in VS/the designer? Because it seems that freezing columns in Dynamics doesn't prevent sorting.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Not on the visual studio designer. Its available in the form itself(UI). Select the control and click on freeze.

    If you freeze the column you wont see the lookup filter when you click on form control.

    Thanks,

    Girish S.

  • Dynamics-user-185 Profile Picture
    15 on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Ok that's what I thought. I tried freezing the column (in the web app UI) but it still allows users to sort.

  • Dynamics-user-185 Profile Picture
    15 on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    In the form init() method I'm sorting based on criteria that I want to sort by. Wouldn't this code just... undo my sort fields?

  • Dynamics-user-185 Profile Picture
    15 on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    My apologies, freezing the column from the UI does seem to work.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Please take time to mark answers as verified if its solved your issue. So others can make use of this thread.

    Thanks,

    Girish S.

  • Dynamics-user-185 Profile Picture
    15 on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Freezing the column from the UI does work, but that didn't answer the question or solve the problem. I just wanted to correct that part.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 703 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 582 Most Valuable Professional

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 542

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans