5 Replies Latest reply on Jul 15, 2016 6:13 AM by Stu412

    Select/deselect rows in a portal


      Hi there


      Looking for some technique advice here really.  I have a portal in which there is a list of records representing a contents/index page.  I wish to allow the user to re-order these using up and down arrows.  The use case would be two stage:


      Stage One


      • Click on content row in the portal
      • It becomes highlighted


      Stage Two


      • Click either up or down arrow to move it up or down the portal


      Stage One (Repeated if necessary)


      • Click another content row
      • Previous highlighted row turns off
      • New row is highlighted


      Stage Two (Repeated if necessary)


      • Click either up or down arrow to move second selected row up or down in the portal
      • Repeat as necessary


      This can be done by scripts but I feel they're getting very slow and this is where I need some help just in case I've missed something or there is a better way to do this.


      I have two fields on the child (portal) table, one called SORT and one called SELECTED.  The SORT field is a number which determines where in the portal set the record sits.  The SELECTED field is either Y or N and determines which row you are moving up and down the portal.


      I have an OnEnter script which fires when the user clicks any field on the portal row.


      As I see it, this script needs to:


      • Set Field [SELECTED] of the current record to Y
      • Set all other [SELECTED] records to N


      A second script then organises the SORT field via a button setup defined against Up and Down arrow images.


      As I see it, this script needs to:


      • Set Variable of the SORT value of the current record
      • Increase or decrease by one to change its position in the sort order
      • Renumber the remaining records correctly to maintain order (prevent something like 1,2,5,7, instead give us 1,2,3,4)
      • Check the new SORT value is not <0


      As I say, I may well be over complicating this, but it needs to be a slick routine so that people can and will use it.


      Thanks in advance

        • 1. Re: Select/deselect rows in a portal

          You may want to google FileMaker portal dragging.

          Are you looking for something like this:

          Better Drag Sorting — Delfs' Engineering

          1 of 1 people found this helpful
          • 2. Re: Select/deselect rows in a portal

            It seems to me like you've got a good handle on it to me. I would think you wouldn't see any performance issues unless you have hundreds of records in the portal.


            v.15 introduced some changes for more optimized loading of portals, so you may want to test your solution on the latest version.


            You may also want to check the existing work people have done that is similar for ideas.


            Portal Row Reordering using Drag & Drop - ISO FileMaker Magazine


            NightWing Enterprises - Portal Control System for FileMaker Pro 13 


            Also, I believe you can just use theme styling to style the "Active" portal row. So you may want to just do that, and then figure out how to retain the "active" state of that portal row as it is changed in position.

            • 3. Re: Select/deselect rows in a portal

              I don't think you need the "Selected" field at all. Put the up and down arrows in each row of the portal. When an arrow is clicked, the row in which it is clicked will be the selected row. One click would do what you're after, instead of one click to select (and mark all other records in your portal with "not selected") and then one click to re-order. The "Selected" method is adding a lot of overhead while at the same time making the user click more times than necessary.


              Bigger question...is this a multi-user solution? By using a field like Sort, any user will be affecting the value in the Sort fields for all other users. If you stick with the "Selected" method, the same would be true for that field. Let's say I'm looking at the same 10 records as you are. You select row 7. It highlights on your machine, and my machine would see it as "selected" at the same time, even though I'd selected row 3. I re-click row 3. Your "selected" row would then become row 3, too. The Sort is workable, since it probably SHOULD apply to all users.


              How is the initial sort set? You select all records for a given project, then use "replace field contents" to set sort to a serial number? In other words...does "Sort" contain valid values (e.g., 1-10) as soon as the portal is viewed? If you already know that the records are numbered sequentially, then your script would 1) test to see if the user was on row 1 when the up arrow was clicked, and ignore that action, 2) test to see if the user was on the last row when a down arrow was clicked, and ignore that action, 3) if the user clicked on any "movable" row, then the direction would be set (up or down), and the two affected rows would be known. Clicking "down" on row 2 would mean "Sort" for row 2 should become 3 while "Sort" for row 3 would become 2. No need to change any other numbers. Have your script set the Sort value for row 2 to 3, then go down one row and set the Sort value to 2. Then commit the records and refresh the portal object (which you will name using the Inspector).

              • 4. Re: Select/deselect rows in a portal

                You're on the right track. I see two places for improvement.


                1) You don't need a field to track "Selected", you can use a variable instead. You can either reset the variable on record load or tie the variable to the current record by using variable repetitions.


                2) You don't need to reset the sort order of any other records. You just need to make sure the sort order of the selected record ends up between the "previous" and "next" records. So, you don't need the sort "number" to be an integer. Eventually, with enough "moving around", your sort order could be 1, 2, 3, 3.121, 3.13, 3.2, 4, 4.5, 5, 5.21, 6 or something. That will save you a lot of overhead.

                • 5. Re: Select/deselect rows in a portal

                  Thanks for everybody's help on this one.


                  I've managed to implement the Delf's Engineering example into the DB I'm using.  The cartesian join that allows the drag and drop also prevents the direct editing of text when it's on the portal, but this was easily overcome and actually offered an improvement on my original portal by including a pop over in the portal to edit the portal row.