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" ),
Discussion posts and replies are publicly visible
HI Akhil, Could not understand your requirement exactly. could you please explain little bit more?
Hi Gopal,
In a grid row layout, I have provided an icon at the end of each grid row. Once I click on that icon, new row with the data should get appended to the layout. For example if we have 5 rows and we cloned the first row, the new row should get added in the second position. But right now with the above code, it is getting added in the first position.
The insert function takes an index for where to add the item. Your definition of that index seems weird. Did you try just ri!index? And does ri!index contain the expected value?
I tried with ri!index. Also printing the ri!index value and it has the expected index. But still when I clone, new row is adding at the starting position i.e at index 1
Hi akhilag7167
Can you please try with the "ri!index+1" for the index parameter in the Insert function.
It seems the index value you have given in the Insert function is to add the value at the same row. Please refer the below code
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, ),ri!index+1, ) ), ), linkStyle:"STANDALONE" ),
Hi AnuPriya,
It is working fine with the above code. But I'm facing a problem. When I clone a row, it is adding at index 1 initially. But when I save and come back to the screen again, it is appearing a correct index. Don't know why this behaviour is happening.
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?
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.