Reading data from Ajax Source

Reading data from Ajax Source

darzrendarzren Posts: 1Questions: 1Answers: 0

I am populating my Datatable from Ajax Source with a text input within.

But have not been able to read the row data from DataTable.

Not sure if below information is sufficient for anyone to help. Otherwise, i can provide more details.

My intention is to perform entry to the Received Qty field and have all rows posting via Ajax.

Thanks.

   <table class="table" id="receiptlinetbl" style="width:100%">
                        <thead class="thead-dark">                     
                            <tr>
                                <th>PurchaseOrderLineId</th>
                                <th>Sku Description</th>
                                <th>Expected Qty</th>
                                <th>Received Qty</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>


 var receipttable2 = $("#receiptlinetbl").DataTable({
            ajax: {
                "type": "GET",
                "url": "/api/PurchaseOrderLine/GetLines/" + id + "",
                "dataSrc": function (data) {
                    //alert(data);
                    return data.lines
                }
            },
                "columns": [               
                    { "data": "purchaseOrderLineId" },
                    { "data": "sku.description" },
                    { "data": "expectedQty" },
                    { "data": "receivedQty", "defaultContent": '<input type="text" value="0" size="10"/>'},      
                ],
                "language": {
                    "emptyTable": "data is empty."
                },
                "lengthChange": false,
                "bFilter": false,
                "paging": false,
                "info": false
        }); 


        var test = receipttable2.rows().data()[0]; 
        alert(test);

Answers

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

    Have you considered using Editor? As that would make this much simpler,

    Cheers,

    Colin

This discussion has been closed.