¿How can I select many items from a selec Item and add them to a Table Widget?

1
0
-1

Hi all

I am a newbie at Bonita 7.2, and my doubt is:
I have a select of items with some researchers, and I want to select one of then, them push a button to add this to the Table widget. In the next step I want to select another different researcher from the select, and push again in the Add button and then automatically add this element to the same table widget, in this way I want to continue adding elements to this table Widget.
I have tried it with the field/property "Action" of the button, selecting the value "Add to a collection", and certainly it adds elements to the collection because I display it in a text field/JSON, but it doesn't display this values in the Table Widget.
This is the list mapped with the Table Widget

  1. Researchers selected:[ "Pedro Rodríguez Méndez", "Luis Concepción del Castillo" ]

But the table is always empty.

I think I have to do something like these tutorials:

You can find an example on the link below, download and import the process.
https://github.com/Bonitasoft-Community/vacation-management-example

Basically, it uses the "selected row" variable from the table, and a request to the business object with the "context" of the task.
It works well.

If you want to create your own customized request within Bonita Engine, take a look at the following link :
https://github.com/Bonitasoft-Community/rest-api-sql-data-source

EDITED, New Information:

Sorry, let me explain better, the table does add new row, but this new row is empty, I suppose it is because the list that I am passing to the Table is a simple list like this:

  1. Researchers selected:[ "Pedro Rodríguez Méndez", "Luis Concepción del Castillo" ]

And I think it should be something like this to make it work:

  1. Researchers selected:[
  2. {
  3. "name": "Pedro Rodríguez Méndez"
  4. },
  5. {
  6. "name": "Luis Concepción del Castillo"
  7. }
  8. ]

I think it is mandatory, a must, to give a hashMap to the table Widget, in the json, with the structure:
[{"key":"value1"},{"key":"valu2"}]

Thank you very much.

Any assistance would be greatly appreciated.

Kind regards,
Héctor

1 answer

1
+1
-1
This one is the BEST answer!

In your add button you need to add code similar to

  1. $scope.doSearch = function () {
  2. $scope.tableParams.reload();
  3. }

to tell the table to reload the data,

regards
Seán

PS: If this reply answers your question, please mark as resolved.

Comments

Submitted by hectorta on Thu, 07/28/2016 - 10:05

To add this code, I have to create my own custom button widget, because in a common button oi can't add any code.
I suppose I have to take the generic widget of a button and add this code that you say.
Am I wrong?

Thank you very much

Submitted by hectorta on Thu, 07/28/2016 - 10:24

Sorry, let me explain better, the table does add new row, but this new row is empty, I suppose it is because the list that I am passing to the Table is a simple list like this:

  1. Researchers selected:[ "Pedro Rodríguez Méndez", "Luis Concepción del Castillo" ]

And I think it should be something like this to make it work:

  1. Researchers selected:[
  2. {
  3. "name": "Pedro Rodríguez Méndez"
  4. },
  5. {
  6. "name": "Luis Concepción del Castillo"
  7. }
  8. ]

I think it is mandatory, a must, to give a hashMap to the table Widget, in the json, with the structure:
[{"key":"value1"},{"key":"valu2"}]

Thank you very much

Submitted by hectorta on Thu, 07/28/2016 - 13:29

Do you mean I have to add an api rest extension to add this element by the API Rest to the list(Process variable)? and then refresh the table in the view with the new element.

Thank you very much

Submitted by hectorta on Thu, 07/28/2016 - 15:14

Thank you, perfect, I copied the code from: http://localhost:8080/designer/#/es/widget/pbButton

The code of a common button, and then I added the code of "Sean McP".

I also have to add this in the field values to add: {"nombre":investigador}
Because the table need a JSON with {"key": "value"}

Thank you very much

Submitted by hectorta on Thu, 07/28/2016 - 15:16

Is there a better way of doing it?

Notifications