many thanks for this answer. A big step Forward for me!!!
But now i have a next Problem and perhaps anyone has an idea!
I have this Custom widget in a repeating Container and now Only the first repeating widget is calculation correctly.
If i made changes in e.g. the second, then the first one is recalculated.
Hello Sean,
there was a little bit a misunderstood. You described how i can calculate the total of the overall entries in the repeating Container. Thats great and also a Problem of me. Many thanks.
But my origin question is i think an easier Problem. I changed a Little bit my widget that you can easier understand my Problem. The widget has two fields, the Input of the first is copied in the second field.
My Widget:
Template {{environment.component.name}}
Quelle:
Ziel:
Controller:
function ($scope) {
this.copy = function(){
If i insert this widget in a repeating Container then only the first repeating element is calculated (copied).
If you enter a value in the second (e.g.) repeating field, nothing is copied in the Destination field. I think, the function in the widget copies always only the values from the first repeating entry.
How can i handle this? Is this a Problem of the scope of the function?
OK well you can’t just use the widget as is…you need to change it accordingly.
However to help you along in this case:
The total field needs to be separate so just create a separate total field at the bottom (I suggest a custom field as you can give it an id, standard widgets can’t have one (as yet)) and remove it from the widget I gave you.
Create a simple unique CSS Class that does basically nothing and add it to the input fields in the already existing widgets.
In the code change getElementById to getElementByClass which will pick up all our Class items, then loop through the collection with code something like this:
var summation = 0;
for (each item found in Class){
if (number){
summation = Number(summation) + Number(itemInClass);
}
}
and put it into the total field as previously.
I haven’t got time to do it, but this will get you there with a bit of research into JavaScript etc.
Do not use the Supplied Buttons above, for some reason they refuse to work correctly, and despite bringing it to Bonitasofts attention, it’s low priority.
To Show Code/Logs correctly use
< code >
your code/log
< /code >
removing the spaces to allow the showing of code/logs correctly as here:
your code/log
You should still be able to edit your post to ensure the correct formatting of the code to help us understand it easier.
If i insert this widget in a repeating Container then only the first repeating element is calculated (copied). If you enter a value in the second (e.g.) repeating field, nothing is copied in the Destination field. I think, the function in the widget copies always only the values from the first repeating entry. How can i handle this? Is this a Problem of the scope of the function?
As we’re using JavaScript to directly manipulate the DOM this will always happen, it will use the first element called pbOutput
I think you’ll have to design it another way or use a different method (for example a third party table).
I only designed the widget to have one Summation field, you’re looking at a summation field per row…something completely different and unfortunately I don’t have an answer for that.
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.