Skip to main content
August 22, 2022
Question

Add rows in editable grid

  • August 22, 2022
  • 4 replies
  • 0 views

I want to add multiple rows in an editable grid layout by selecting a number using Interface

4 replies

richardm900458
August 22, 2022

you can use a richtexticon with dynamiclink.
on the editbale grid array you are displaying. you can append (append()) the new values through a combination 
of a!foreach which has an enumerate() as "items" paramater and the expression parameter a certain the map/cdt type etc.

stefanhelzle0001
Brainy
August 22, 2022

You use the same logic as with the addRowLink parameter of the grid layout component. The only difference is that you create more than one new item.

August 22, 2022

In the add new row configuration, you can create a for loop to create more than 1 new row at a time.

peter.lewis
Employee
August 22, 2022

Like others mentioned, you can make the add row link add whatever you want, whether it's 1 or 100 rows. However, you should think about what the user experience will be like too. I'd recommend that the actual link at the bottom of the grid always returns 1 item, but you add another place that lets you add multiple rows.

Here's an example within the product where we do this. If you want to just add a single row, you use the basic plus icon. However, adding multiple rows has a separate icon where you can designate how many rows you want to add.

To actually achieve this, you can then update your append rule to repeat how many items should be added, like this:

addRowLink: a!dynamicLink(
  label: "Add Employee",
  saveInto: {
    a!save(
      local!employees, 
      append(
        local!employees, 
        repeat(
          10,
          recordType!Employee()
        )
      )
    )
  }
),