Calculated Value in Datagrid

Hi all!

I have a datagrid with two columns that a user can edit, and a third read-only column which is the product of the first two user-editable columns.

What’s the best practice for the calculation? Do it in WeWeb and then send the calculated value to Xano? Or have Xano do the calc and then return it to WeWeb?


You can use a custom readonly column on your datagrid.
Then drag and drop a text inside the flexbox which appears when toggling the column type to custom.
Bind the text content to your formula :slight_smile: (context.item will contain your row)

If the calculation is easy (just a product), it’s always best to do it in front, to avoid corrupted data in the back (someone sending a value which is not the formula you want from the two others). Its also avoid storing too many data.

Note: it can be usecase when you want to have this column in the back (for sorting per ex), but in this case i advice that your post endpoint do the math before saving the data, not the front.


Worked perfectly thanks @aurelie! :star_struck:

And just to show you what I ended up with, I used the incredible AI co-pilot to generate some custom JS to format the output with a $, commas and two decimal places. Worked first time! Amazing.

1 Like

Awesome to see folks using the AI tools. When I have a project it fits, I’ll be sure to check it out.

1 Like

@aurelie I did end up calculating the product in Xano as I will need it for other purposes. It’s ok to calculate the sane thing in two places? Why not just have Xano calculate it and return the total to the front end? Or have the front-end submit the calculated value to Xano? Either way it just feels wrong to calculate it twice. Am I overthinking?

If finally you end up needed it on the database, I advise you to have it handle by the backend only.

  • The get should return the product
  • The edit should only accept the two others parameters, and your backend will do the maths before pushing in the database
  • in your datagrid you mark this column as read-only (no edit), and you can go back to a normal text column or keep the custom one but bind to the field of your backend instead of doing maths.

A reason to do the maths in front would be to have instant feedback while editing the other values (so you see the result before the backend process it). Can be a good user experience depending on your workflow.

Edit: I just watch your video, and I think you have the correct approach (modulo the eventual user feedback when editing). Only suggestion: I am not an expert in xano, but maybe do the maths and make only one update to the DB instead of push/read/push again (do not know if possible)

1 Like

Thanks again @aurelie. Yes in this case doing it in the back-end seemed correct. I will see if I can streamline the API further per your suggestion.