Keep or Set Selectionfilter from code
Juhl
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?
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
0
Best Answer
-
I think NAV loses the selection not because you're updating the records, but because it needs to redraw the page to reflect the new display order. For that reason I don't think you will be able to achieve moving blocks of selected records in code in any way, because no matter what method is used to change the sorting it will always require page redraw
Slawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;5
Answers
-
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 - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;0 -
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 ideasFollow me on my blog juhl.blog0 -
I think NAV loses the selection not because you're updating the records, but because it needs to redraw the page to reflect the new display order. For that reason I don't think you will be able to achieve moving blocks of selected records in code in any way, because no matter what method is used to change the sorting it will always require page redraw
Slawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;5 -
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 - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;0 -
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 - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
