Step 8 – Portal Enhancements
At the very beginning of this workshop, you created 4 cartesian relationships in order to be able to view all the records in those tables; the main purpose of this was to avoid the need to go into Find mode to lcoate a record.
Now it’s time to change things up but don’t worry, you’re only going to have to make minor changes to what you’ve already completed.
Let’s start with Companies, as you will often find yourself with a largish number of them.
In the Companies table, you will find a field called Index. This is a calculated field and is the 1st letter of the Name.
Now change the H_Companies relationship to connect the new field, G_CompanyIndex, to the Index field in Companies, changing the operator from x (cartesian) to =.
On the Companies panel, Add the field G_CompanyIndex to the left of the portal. (You will notice that there are no names in the portal.)
Now click on that field and add a radio button value list called CompanyIndex which shows all values from the Index field in Companies.
Two things to notice here. The first is that you have only a few letters of the alphabet. The reason for this that, currently, there are only Companies that begin with those letters. This is dynamic and will change as companies are added or deleted.
The second thing is that nothing shows in the portal and that to see records, we have to click on an index letter but before we can do that we have to set a script trigger to that field so that OnObjectModify, it runs the script CommitRefresh.
Now, you’re probably thinking, but what if I want to see all Companies without having to make a selection?
Don’t worry, we’re just about to cover that. This will require a new calculation field and changing the relationship once again (and for the last time).
The calculation field that we are going to create is to the right. It simply says that if G_CompanyIndex is empty (has no value) then use all values from the value list CompanyIndex. Otherwise use the value that is selected.
Because I use this calculation all the time, I’ve created a custom function to save me work and you’ll find that CF in the program file.
Here is the custom function called category_filter
All we have to do now is make one final change to the relationship H_Companies.
But what if I have an index letter selected and I want to go back to all?
You can deselect a radio button by holding down the shift key while clicking on the selection.
However not everybody knows that so let’s make it really easy. Let’s add one more global field.
And make that a radio button using the value list All
And finally we set script triggers to clear one field when the other is selected.
The beauty of this technique is it eliminates any chance of confusion in the user’s mind and it also appears to be just one single field of radio buttons with an ALL option at the top.
Yes, it is quite a bit of extra work to get there but wasn’t it worth it?