6 Posts
waby
6 years ago
17
Topic

Hello,

Could you please tell me how can we do the sum of a column in a list ?

Get a VIP membership
4229 Posts
Kadministrator
6 years ago
1
Level 1
6 Posts
waby
6 years ago
0
Level 2

Thank you

103 Posts
shubhaanshu
6 years ago
12
Level 1

Hi Friends,

I figured it out in one of my projects like this sometime ago, added these lines of javascript in the templates index file:

<script>
$(window).load(function(){

var sum = 0.0;
$('.total').each(function()

// .total is the class name for the field to sum
{
sum += parseFloat($(this).text());
});
$("#tableid").append("<tfoot><tr><td colspan='6'>Total: " + sum + "</td></tr></tfoot>");

// #tableid is the id of your list table

</script>

-------------

may be it will help you.

Shubhaanshu

6 Posts
waby
6 years ago
0
Level 2

Thank You

27 Posts
Isaac Valente
6 years ago
10
Level 2

Good Morning. I'm trying to do as you said, but I do not know where to put the codes, can you explain me?

4229 Posts
Kadministrator
6 years ago
9
Level 3

Hi,

you can add javascript to seblod pages using various methods, e.g. in seblod configuration  (for all pages), using javascript code field or in js section of configuration of each field

27 Posts
Isaac Valente
6 years ago
8
Level 4

Thank you Klas, but in the example of our friend shubhaanshuhe says to put and change the name according to my project of the class of my field that I want to add and also the ID of my table, but what I can not find is the ID of my table, I checked the source code for the frontend, but the table does not have an ID, have junt CLASS. I hope you can help me. Hugs.

103 Posts
shubhaanshu
6 years ago
7
Level 5

Hi Isaac,

Actually I edited the index file under seb_table, which I think is not the good way, so you can assign a unique class to the template then use it as the jquery selector (use .youruniqueclass instead of #tableid)


Best Regards,

27 Posts
Isaac Valente
6 years ago
6
Level 6

I must be doing something wrong ... follow the pictures to help me better.

103 Posts
shubhaanshu
6 years ago
5
Level 7

As I can see that everything is correct and it should work perfectly...

Can you please try again by adding jquery :

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

27 Posts
Isaac Valente
6 years ago
4
Level 8

Morning, I tried, but don't work. :(

103 Posts
shubhaanshu
6 years ago
3
Level 9

Hi Isaac,

please go to the link it is the detailed working code (view the source code): Column Total

If you still face any issue please send your admin details and I will be happy to solve it for you...

Regards

Shubhaanshu

27 Posts
Isaac Valente
6 years ago
2
Level 10

I am immensely grateful. how can I send you the access information?

103 Posts
shubhaanshu
6 years ago
1
Level 11

I am here

27 Posts
Isaac Valente
6 years ago
0
Level 12

I sent the information through the contact form

27 Posts
Isaac Valente
6 years ago
1
Level 1

I did it, shubhaanshu helped me, thank you.

1283 Posts
Bucklash
6 years ago
0
Level 2

It would be cool if you shared your result or made tutorial :)

 

Get a Book for SEBLOD