Can I do a submit like this

Can I do a submit like this

orionaseliteorionaselite Posts: 49Questions: 13Answers: 4

assume I have a datatable with some fields and after initialization I do some calculations using on.draw as my trigger event
these calculations are visible after doing them and running this and many more like it for some other cells

$('#portfolio').dataTable().fnUpdate( price_usd, index, 2,false); // Single cell

can i do something to set the value to update I mysql like

editor
.set('price_usd',price_usd)
.submit()

I don't think I can do this now since I am not using the editor the set the values. I am using js code I want to submit all my changes to the db as they are shown on the table

ideas?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    If you are calculating the value to display, why would you also want to save it to the database? I'm not quite clear on the use case, and therefore not sure what the best answer would be.

    Allan

  • orionaseliteorionaselite Posts: 49Questions: 13Answers: 4
    edited August 2017

    Well, assume this I have a table that has three values num_items,price and total in my db
    initially my db has the values num_items = 3 for example,price = 0 and total =0. assume I need to get the price at some point from an external api.

    i need to make an external api call to get the initial price which I have accomplished and set on the table via

    $('#portfolio').dataTable().fnUpdate( price, index, 1,false); 
    

    assume the api gave me a price today of 2 for my item
    now lets say I do a calculation today

    var total = price*num_items;
    

    total today is 6

    Now tomorrow if I look at the table and I don't save that row data from yesterday and the API gives me 3 as a price for that item than total would be 9 but I need to remember yesterdays total based on yesterdays price as well.

    So basically I want to save todays data as is and tommorow if prices change I will add rows with the new price and total but when I look at the table I want to see what the price and total was yesterday too.

  • orionaseliteorionaselite Posts: 49Questions: 13Answers: 4

    one solution would be to do an $.ajax put i thought maybe Datatable has another way. consider this solved I guess. Thanks for the assist either way

This discussion has been closed.