Keep or Set Selectionfilter from code

JuhlJuhl Member Posts: 724
Hi Guys

Stumpled on a need to select multiple records in a listpage, run a function, and then keep the selection afterwards.
But af running the function, that alters records, the selection is lost.

I have the selection in a record saved with SETSELECTIONFILTER, but can i pass that back to the page?
Follow me on my blog juhl.blog

Best Answer

Answers

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    I'm not sure if you can set the selection (like highlight the records on the page) in the code at all. Never stumbled across such a possibility in NAV.

    You could, however, mark them, by looping through the var where the selection has been saved and marking the records in Rec variable. Not exactly the same, but may be sufficient?

    Also, you could look into how you modify the records, maybe this bit can be changed to avoid losing the selection?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • JuhlJuhl Member Posts: 724
    Hi Slawek
    No thats not gonna be enough.
    The function i have made is updating a sorting number, to move records up and down. When the users only moves one record, I use get afterwards, to highlight the record just moved, so the users can just presse the UP button 10 times to move it up 10 places. But this can also be done with multiple records, and it’s not user friendly to mark all records for every push of the up or down button.
    But after changing the records I loose the highlighting of the records.

    Maybe the user could enter the replacing sorting number instead, and make that visible. Instead of the up/down button for multiple records?

    What do you think? Or any other ideas
    Follow me on my blog juhl.blog
  • JuhlJuhl Member Posts: 724
    Yes, that’s what I came to as well.
    I’m gonna look at the solution to enter the replacing sorting number instead.
    Thanks Slawek
    Follow me on my blog juhl.blog
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    edited 2018-01-07
    On a second thought - try with MARK.

    Try to add a column to your page and use the MARKED property as a source. When you have a selection made by the user the first thing in the code would be to mark all selected records and then update sorting order. Subsequent calls to move up/down would check if something is already marked and if yes just update the sorting column without re-marking records.

    Exposing MARKED as a column would let the user see what she/she selected in the first place, the code moving rows would work, and the marking would not be lost after changing sorting column.

    It is nice functionality from user experience/usability point of view, but I can see the troubles coming. What will happen if a user clicks any header and change the sorting order on the page? It's gonna be a little complicated to make such a functionality foolproof.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • JuhlJuhl Member Posts: 724
    Cool, I will test it, but see your point.
    Code and a button to clear MARKED should be implemented.

    Thanks.
    Follow me on my blog juhl.blog
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Yep, the code and a button to reset mark may be helpful, but you could also try to detect if something has been re-selected after you have marked the records and if so drop the old marking and set the new
    ones.

    I'm more concerned with moving the block up or down in the code. It's because the 'up' and 'down' has to be analyzed and updated in the context of current display order, which will be different to your hidden sorting column once a user clicks any column header.

    To make it work all the time you would need to either disable sorting (for example by using an expression in every column SouceExpr) or to detect the current sorting order and re-seed your hidden sorting column before moving the block up and down.

    Secondly, you probably need to make the page to work on a temporary record to avoid hidden sorting column update conflicts if more than one user opens the same page at the same time.

    It looks like it would need quite an effort to make it work nicely and trouble-free.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • JuhlJuhl Member Posts: 724
    Thanks Slawek

    Just got sidetracked with a more important case, but will look into this.
    Follow me on my blog juhl.blog
Sign In or Register to comment.