Get value of form input of row after search

Get value of form input of row after search

jigar311982jigar311982 Posts: 70Questions: 31Answers: 0

Hello,

I have below code which I am using to finding row and get data of same based on my Ajax input,

    //First we need to find that row and get value for same.
    var matchRow = table.row( function ( idx, rowdata, node ) {
        return rowdata.item_id === data.response.item_id ? true : false;
    });
                            
    // Get row data
    matchData = matchRow.data();

    //Increase value in spin
    $('input[name="item_quantity"]', matchRow).trigger("touchspin.uponce");

    var new_item_quantity_r = Number(matchData.item_quantity_r) + Number(1);
    matchData.item_quantity_r = new_item_quantity_r;

    matchRow.data( matchData ).draw(false);

Now my datatables have rowcallback as well,

            rowCallback: function (row, data) {
      
                // Get input val of item_quantity input
                var item_quantity = $('input[name="item_quantity"]', row).val();
          
                // Set to 1 if undefined or blank
                if ( item_quantity === '' || item_quantity === undefined ) {
                    item_quantity = 1;
                }
                
                // Multiply Price by Quantity
                var total = data.item_price * item_quantity;
                
                // Save in Total column
                this.api().cell(row, 5).data(total);

                this.api().cell(row, 1).data(item_quantity);

            },

Now my problem is, when i try to update row wth Ajax, it takes this item_quanity, because in my first code $('input[name="item_quantity"]', matchRow).trigger("touchspin.uponce"); i could not get value of row form input which i could bale to get in rowcallback as var item_quantity = $('input[name="item_quantity"]', row).val();

How can I get the value of form input after searching row?

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.