Adding rows at specified position in a grid

Hi,

I need to add a grid row right after I cloned(click on a link) the first one. I have used insert function for that.

But still, the row is adding before the main row i.e at the starting of the grid rows

Co

a!richTextItem(
          text: a!richTextIcon(icon: "Add", caption: "Create Rows"),
          link: a!dynamicLink(
            value: ri!data[ri!index],
            saveInto: {
              a!save(
                ri!data,
                insert(
                  ri!data,
                  'type!{urn:com:appian:types}C_CDTName'(
                    Id: ri!data[ri!index].Id,
                    HeaderLine: ri!data[ri!index].HeaderLine,
                    Desc: ri!data[ri!index].Desc,
                  ), (wherecontains(ri!data[ri!index],ri!data)),
                )
              ),
          ),
          linkStyle:"STANDALONE"
        ),


Could anyone please help me on the above issue. Thanks in advance

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi 

    The issue seems to be at the index parameter on the Insert function. You have given as (wherecontains(ri!data[ri!index],ri!data)), which will return the current index (i.e. the row from which you click clone icon).

    For example, if you clicking on Clone in first row, (wherecontains(ri!data[ri!index],ri!data)) expression will return 1 as index in Insert, so the row is adding at first instead of 2nd row. 

    I didn't understand how you evaluated that after saving and come back to the screen, shows correct index, because after cloning, the first and second row looks identical.

    Can you please explain how you are saying that saving and come back to the screen, show correct index?

  • 0
    Certified Lead Developer
    in reply to akhilag7167

    This is probably because you do not manage the variable ri!index correctly. You might have to update ri!index with the row you click before inserting.