Skip to main content

Notifications

Announcements

No record found.

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.

  • GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 on at
    RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Yes its not freezing column when you do it programmatically. But when you right click the column it will show option for unfreeze but its not actually freezing the column.

    Thanks,

    Girish S.

  • RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

    Also, it looks like right-clicking the control in the UI and hitting 'freeze' does disable the ability to sort/filter the column, but setting it programmatically in the form with an override does not?! Do you happen to know why that might be?

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

  • GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 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.

  • RE: Overriding sort(SortOrder _sortDirection) method on column in FormControlGrid

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

  • 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?

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

  • GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 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.

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

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

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans