Auto Numbering Sorting with Previous Row

Hi,
i understand to use increment to make auto numbering.

  1. Quotation
  2. Part Requisition
  3. Service
  4. Invoice
  5. Payment

But let say we deleted number 3. how to make other number affect too? Let say, this case,

  1. Quotation
  2. Part Requisition
    (deleted)
  3. Invoice
  4. Payment

There is a technique based on the usage of a Row ID column. Conceptually, since Row IDs are automatically added or deleted when a row is added or removed, this technique allows dynamic row indexing (or row numbering).

  • Add a basic Row ID column.
  • Add a basic lookup column that points to the Row ID column. You will get a column where each cell represents an array of all the Row IDs.
  • Add a computed Find Element Index. Point the first field to the lookup column (the arrays), the second field to the Row ID column (the element whose index you are finding), adjust the display of the number to 1 (no digits after the comma) and no units.

Now you should have a column of numbers starting at 0 and automatically incrementing by 1 on each new row.

Should you want the row numbering to start at 1 instead of 0, add a computed math column and add 1 (+1) to the index column.

I got it!
But it is possible to do sorting ? Let say,

In in-line,
i plan to add one button to move up one level.

Let say,

  1. Quotation
  2. Part Requisition
  3. Service
  4. Invoice (click once)
  5. Payment

then it will be:

  1. Quotation
  2. Part Requisition
  3. Invoice (click one more time)
  4. Service
  5. Payment

It become:

  1. Quotation
  2. Invoice
  3. Part Requisition
  4. Service
  5. Payment

Yes, the technique I explained works fine with the sorting you showed.

There are a few places you can sort:

  • In the Data Editor, in a Query column
  • In the Data Editor, with a Sort Array column
  • In the Layout Editor, in the options panel (right side) of a collection component.

I think sorting in the Layout Editor would be a sound approach.

You mean this one ?

I want to ask you, meaning i need another one more column basically for sorting purpose right?

Yes, that is the place in the Layout Editor where you can sort a collection. In that area, you can define what attribute (column) you wish to sort along and then adjust the sorting options accordingly.

For instance, the table of a collection could have Row Index, Name and Date of Birth columns. You could sort along the Row Index column (which would be the same as sheet order), or Name, or Date of Birth. Same collection, different sorting result depending on the sorting attribute.

The sorting part isn’t easily achieved. Nathanael’s method helps you add an index column, but that is a computed column and can’t be incremented or decremented.

If you can add a number column and add an index number every time you create a new record, then you increment/decrement and sort by that column when you move up or down the scales.

You must make sure that you also increment/decrement the items surrounding the items you are moving up or down to make it work.

Say you move Invoice from 4 to 3, then Service must be moved from 3 to 4 as a result.

In the end, it will likely be a combination of queries to get the “previous” and “next” row, then incremental actions.

2 Likes

Meaning, Nathan’s method is only for numbering right ?
The sorting part is different part.

Yes, I would say so.

Have you ever did before ? Hehe…

No, I don’t have a use case for this. Please try to do it yourself based on the idea above and let us know if you get somewhere.

Ok Thinh, thank youuuu

1 Like

@ThinhDinh ,

I just found this thread. I managed to do what i need, based on your idea. Hehehehheheehe, thank you.

What did you eat everyday eh? because so brilliant.

1 Like

But…one more question.
Do you know any ‘hack’ to make the button up and down prettier ?

How do you define “prettier”? That looks fine to me.

or maybe different color? or not in box?

Unless you have access to CSS, that’s not doable, but I would keep it as is.

oh i remember the last version we simply can use it on rich text right?

Only on Classic Apps. In the new apps, you only have access to Glide’s CSS input on Business/Enterprise.

That said, I don’t think that design looks bad.