使用数据表分页时,数据绑定在knockout.js中不起作用

e0bqpujr  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(127)

我正在使用Knockout.js将列表绑定到表中。在此,为了排序和分页,我使用了数据表。在第一页,数据绑定工作正常。但是如果我移动到第二页,它就不工作了。如果有人能帮助我,那就太好了。我是Knockout.js的新手。下面是我的代码

<table id="datatable" class="table table-bordered thumbnail-table ">
    <thead>
        <tr>
            <th width="8%"> Pip Code</th>
            <th width="30%">Full Description </th>
            <th width="20%">Product Description </th>
            <th width="5%">Size</th>
            <th width="5%">Quantity</th>
            <th width="10%"> Manufacturer </th>
            <th width="10%">Brand Name</th>
            <th width="5%"><input type="checkbox" data-bind="checked: selectAll" /></th>
            <th width="10%">Stock</th>
        </tr>
    </thead>
    <tbody data-bind="dataTablesForEach : {data: items,
                                            options: {
                                                paging: true,

                                            }}">
        <tr data-bind="click: $root.selectRow">
            <td data-bind="text:$data.pipCode"></td>
            <td data-bind="text:$data.fullDescription"></td>
            <td data-bind="text:$data.productDescription"></td>
            <td data-bind="text:$data.size"></td>
            <td data-bind="text:$data.quantity"></td>
            <td data-bind="text:$data.manufacturer"></td>
            <td data-bind="text:$data.brandName"></td>
            <td><input type="checkbox" data-bind="checked:$data.include,click: function(){return true}, clickBubble: false" /></td>
            <td><input type="text" style="width:50px" class="form-control" data-bind="value:$data.stock,click: function(){return true}, clickBubble: false" /></td>
        </tr>
    </tbody>
</table>
jjhzyzn0

jjhzyzn01#

我知道这个问题是不久前发布的,但是对于其他发现这个问题的人,您应该查看this article tl; dr KnockoutJS无法绑定到被DataTables分页隐藏的HTML元素

相关问题