テーブルにはDatatable
を使用しています。私はDataTable
が作成された後、更新されたデータに関するいくつかの問題に直面しています。HTML-JSでDataTableを変更するにはどうすればよいですか?
私は8つのレコードを持っています。ページネーションは5です。2ページあることを意味します。私はチェックボックスの列を持っています。 table.DataTable()
の表を変換すると、データがチェックされ、DataTable.rows()
を使用して問題はありません。
しかし、変更を実行すると、チェックボックスをオフにしたように、テキストボックスの値を変更すると反映されません。 変更後、私はの値をconsole.log
でチェックします。初期化時に同じデータを表示します。
Steps to reproduce
1- Create table and convert into DataTable
2- Console.log table data
3- uncheck few checkbox and add some text in textbox
4- Console.log. It will show same data of Step-2.
コード:
HTML
<table id="products" style="width: 100%; font-family: Segoe UI,Tahoma,Arial;" cellspacing="0" cellpadding="0" border="0">
<caption class="caption-title">Title</caption>
<tbody id="ptbody"></tbody>
<thead>
<tr>
<th>Select Product</th>
<th>Product Name</th>
<th>Qty</th>
<th style="display:none"></th>
</tr>
</thead>
</table>
JS
var ProductList = [];
ProductList.push("A");
ProductList.push("B");
ProductList.push("C");
ProductList.push("D");
ProductList.push("E");
for (var j = 0; j < 5; j++) {
strTableStructure = strTableStructure + "<tr>";
strTableStructure = strTableStructure + "<td><input id='chk_" + ProductList[j] + "' checked='checked' type='checkbox'></td>";
strTableStructure = strTableStructure + "<td>" + ProductList[j] + "</td>";
strTableStructure = strTableStructure + "<td><input id='txtQty_" + j + "' type='text' maxlength='110' ></td>'";
strTableStructure = strTableStructure + "</tr>";
}
$("#ptbody").html(strTableStructure);
var table = $('#products').DataTable();
誰もが時にテキストボックスのユーザチェック/チェックを外したり変更値の変更を反映するためにどのように私をお勧めすることはできますか?
を使用しています。私は、チェックボックスとテキストボックスの最新の価値をサブミットのクリックで得たいと思っています。 'console.log(objDataTable.rows())'は更新された値をリストするべきです。初期段階と同じ価値を維持します。小さな事例を教えてもらえますか? –
@NanjiMange私の答えを編集する前に、マークアップの一部を投稿できますか?私はそれを得ると思うが、ここで私を修正してください。 objectDataTable.rows()を使用してこれらの値を取得した場合、更新された値は与えられません。 – Eric
私は質問に追加しました。提案してください –