New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping one row in calculating row-sum and sum concatenation #873

Closed
9benm2 opened this Issue Apr 16, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@9benm2

9benm2 commented Apr 16, 2015

Hi,

I'm making a table dynamically with JSON.

I am making two sums in this table:
-I have created a row at the top to calculate the sums of each column (with data-math="col-sum").
-I have created a column that will calculate the sums of each row (with data-math"row-sum").

The strange thing happening can be seen in the screenshot attached.

What happens is that the row sum is skipping the 3rd column (with header <0 days), as you can see in the row for SAP and IBM. I did not do anything special with this column (I didn't put an ignore on it for example).

Then the second issue is that the col-sum is concatenating the values instead of mathematically adding them together. If I search in the table, it will update to the right value (32000) though.

Thanks in advance for your help.
Regards,
Ben

screenshot_18

@Mottie

This comment has been minimized.

Show comment
Hide comment
@Mottie

Mottie Apr 16, 2015

Owner

Hi @9benm2!

Next time, I would really appreciate it and it would save me tons of time if you would please provide the HTML for the table and javascript used to initialize the table; or just modify one of the jsFiddle demos (there are a bunch more basic playground demos to work from on the main wiki page). Thanks!

The first issue looks like it's with the math_mask option. When set to '#', zeros will not show up in the format, instead set this option to '0'.

math_mask : '0'

The second issue looks like a bug in the code. When it encounters the IBM row, second column and there isn't a defined data-math="row-sum" in the cell, the parser was returning an empty string instead of zero. That's why the string was being concatenated. I'll push a fix to the master branch to resolve this issue. Please update your widget-math.js file from there :)

Here is a working demo (using the updated widget-math.js file from the master branch of this repo; rawgit might take a while to update).

Owner

Mottie commented Apr 16, 2015

Hi @9benm2!

Next time, I would really appreciate it and it would save me tons of time if you would please provide the HTML for the table and javascript used to initialize the table; or just modify one of the jsFiddle demos (there are a bunch more basic playground demos to work from on the main wiki page). Thanks!

The first issue looks like it's with the math_mask option. When set to '#', zeros will not show up in the format, instead set this option to '0'.

math_mask : '0'

The second issue looks like a bug in the code. When it encounters the IBM row, second column and there isn't a defined data-math="row-sum" in the cell, the parser was returning an empty string instead of zero. That's why the string was being concatenated. I'll push a fix to the master branch to resolve this issue. Please update your widget-math.js file from there :)

Here is a working demo (using the updated widget-math.js file from the master branch of this repo; rawgit might take a while to update).

@9benm2

This comment has been minimized.

Show comment
Hide comment
@9benm2

9benm2 Apr 16, 2015

As a workaroud, I calculated the row totals in the back end in Java. It's working fine now.

I am not familiar with issues in github, as this is the first one I ever reported.

Thanks very much for your feedback. Next time I will provide my code in jsFiddle and try to be more clear :)

9benm2 commented Apr 16, 2015

As a workaroud, I calculated the row totals in the back end in Java. It's working fine now.

I am not familiar with issues in github, as this is the first one I ever reported.

Thanks very much for your feedback. Next time I will provide my code in jsFiddle and try to be more clear :)

@9benm2 9benm2 closed this Apr 16, 2015

@Mottie Mottie added the Widget label Apr 16, 2015

@Mottie Mottie added the Next Update label Apr 26, 2015

@Mottie Mottie removed the Next Update label May 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment