112
Views
4
Comments
Solved
[Data Grid Web] How can i create button with Insert New Row function of DatGrid.
Forge component by OutSystems R&D
41
Published on 14 Dec 2020

Hello,

I know DataGrid have the InsertNewRow function when you right-click on the table, but i need to add button with the same functionality and i can´t figure it out. Hope you can help me

Thank you.

Staff
Rank: #482
Solution

Hello Koya,

You can achieve that by setting into the parameters the structure that you want.
Please check the following example:

GridOS.ExternalAPI.addRow({PO_No: 'Ronaldo', Quantity: 15}, 0, GridOS.GridObject[0].gridId)

Thank you for your question. 

Tiago Pereira

Champion
Rank: #39

Oleksandr Danilov wrote:

Hello,

I know DataGrid have the InsertNewRow function when you right-click on the table, but i need to add button with the same functionality and i can´t figure it out. Hope you can help me

Thank you.


Hi Danilov,

I dont think you can achieve this by DataGrid component.
You have to customize in your case

Staff
Rank: #565

Hi Oleksandr Danilov,

You can achieve this by our ExternalAPI, to add new rows use the method bellow:

GridOS.ExternalAPI.addRow({}, 0, '" + Grid.Id + "');

Parameters:

  • 1st: Datasource for the new row, in this case I pass a blank source
  • 2nd: the Index on where the new row will be placed
  • 3rd: The Id of the Grid, as you can have more than one grid on the same page you need to specify the which Grid you want to handle 

There is a sample attached, hope it can help you achieve your goals.

Regards

Ricardo Valim


 

DataGridButtonAddRow.oml

Rank: #13144

What should I do if I want to set a value for the first Parameter?

Staff
Rank: #482
Solution

Hello Koya,

You can achieve that by setting into the parameters the structure that you want.
Please check the following example:

GridOS.ExternalAPI.addRow({PO_No: 'Ronaldo', Quantity: 15}, 0, GridOS.GridObject[0].gridId)

Thank you for your question. 

Tiago Pereira