Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Duplicating Rows in an Array  (Read 6345 times)
Reuben B.
Four Js
Posts: 1051


« on: October 19, 2012, 05:05:06 am »

I recently had a question from one of my customers about how to duplicate a row in an array.  Right-click Copy Row, and then Insert-Row, Control-V in the first field is a technique that can work but requires many assumptions in order to work successfully and isn't something I'd rely on.

When the DISPLAY ARRAY list modification triggers https://4js.com/online_documentation/fjs-fgl-manual-html/User/NewFeatures.html#list-modification-triggers were being developed, I suggested an ON DUPLICATE trigger, but that is not as simple as it sounds (think of the BEFORE/AFTER/ON CHANGE triggers that would be bypassed which could include duplicate primary key checks).

If we look at our own Genero Studio, we see in a number of places, the x2 icon which allows you to duplicate a row in an array.  It handles the duplicate primary key issue by appending _2 to the key field. 

We also see it in the GAS Administration program, the Clone button allows you to duplicate an entry.

In a typical Query/Add/Update/Remove/First/Previous/Next/Last Menu structure I have in the past added a Copy entry as well.  I would simply initialize a record, copy the values of the current record across, and relied on the fact that in AFTER INPUT we duplicated the AFTER FIELD validation to ensure that the field values were OK.  This would capture the duplicate primary key and do a NEXT FIELD to force the user to change the value of the primary key if they hadn't changed it already.  Alternatively we could've not copied the primary key field and possibly defaulting it to a new value.

I figure the duplicate functionality is handy if you are adding rows to an array and the values of more than half columns are the same as another row.  In that case it makes sense to copy the existing row and edit the few changes rather than to type the whole row from scratch. 

The question is, for our arrays is that something we should built into Genero?  or is something where requirements are varied enough that everyone should be responsible for their own solution.  If we were to add ON DUPLICATE to DISPLAY ARRAY, or a Paste Row local action for use in INPUT ARRAY, or similar type solutions, what if anything around defaults and validation do we need to consider.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines