Sorry if this has been addressed and I missed it, but I need to some help with adding a row to a table created using jQuery. Below is my code for a working table builder in my MVC project. What I need is to add a column to show the row number (index +1) where I've included "row # here". It seems like it should be a simple task but I'm having difficulty finding anything examples for the correct syntax.
That row number will be included in my child table as a line number for the record.
Code:function DetailsTable() { if (dmrDetail.length > 0) { var $table = $('<table/>'); $table.append('<thead><tr><th>LIN</th><th>Part ID</th><th>Quantity</th><th>Reason</th></tr></thead>'); var $tbody = $('<tbody/>'); $.each(dmrDetail, function (i, val) { var $row = $('<tr/>'); $row.append($('<td/>').html(row # here)); $row.append($('<td/>').html(val.PartNum)); $row.append($('<td/>').html(val.Qty)); $row.append($('<td/>').html(val.Reason)); $tbody.append($row); }); $table.append($tbody); $('#dmrDetail').html($table); } }




Reply With Quote