我正在尝试根据特定名称获取行,但我遇到了问题。第一页中的表显示为空,但数据正在第二页中加载。这是一个例子。
第一张照片为空,然后当我点击数字2时,数据就在那里 这是代码
<tbody data-bind="foreach: invoicedatasintable">
<tr data-bind="if : $data.type_txt == 'Repayment invoice' ">
<td class="text-center"><span data-bind="text: $data.invoiced_total"></span></td>
<td class="text-center"><span data-bind="text: $data.paid_total "></span></td>
<td class="text-center"><span data-bind="text: $data.Abbreviation"></span></td>
<td class="text-center"><a href="#" data-bind="click: $root.getSelectedInvoice"><span data-bind="text: $data.rf_reference"></span></a></td>
<td class="text-center"><span data-bind="text: $data.type_txt"></span></td>
<td class="text-center"><span data-bind="text: $data.status_description"></span></td>
<td class="text-center">
<a href="#" data-bind="if: parseFloat($data.invoiced_total()) > parseFloat($data.paid_total()), click: $root.getRepaymentInvoice"><?php echo lang("invoice_table_pay1"); ?></a>
<span data-bind="ifnot: parseFloat($data.invoiced_total()) > parseFloat($data.paid_total())"><?php echo lang("invoice_table_pay1"); ?></span>
</td>
</tr>
</tbody>
问题是,我还有其他发票,如贷款发票和投资发票,所有都来到foreach声明,但我只想拿这个还款发票并将其显示在桌子上,但奇怪的是它转到了下一页。
这是分页代码。
// ****** Processing invoicedatas paging starts here. **********************************************************************
// Sivutuskäsittelyn vaatima total item count
self.TotalNumberOfInvoicedatas = ko.observable(0);
// actual pager, used to bind to the pager's template
// first parameter must be an observable or function which returns the current 'total item count'.
// it is wrapped in a ko.computed inside the pager.
//debugger;
self.Pagerinvoicedatas = ko.pager(self.TotalNumberOfInvoicedatas);
self.Pagerinvoicedatas().PageSize(12);
// Subscribe to current page changes.
self.Pagerinvoicedatas().CurrentPage.subscribe(function () {
self.searchInvoicedatas();
});
// Subscribe to page size changes.
self.Pagerinvoicedatas().PageSize.subscribe(function () {
self.searchInvoicedatas();
});
self.searchInvoicedatas = function () {
// simulate a search
// ie.:
var maximumRows = self.Pagerinvoicedatas().PageSize();
var startIndex = (self.Pagerinvoicedatas().CurrentPage() - 1) * maximumRows;
self.invoicedatasintable(self.invoicedatas.slice(startIndex, startIndex + (self.Pagerinvoicedatas().PageSize() * 1)));
};
// ****** Processing invoicedatas paging ends here. **********************************************************************
我正在初始化数据的代码。
self.InitializeInvoiceViewModel = function () {
var string =
$.ajax({
type: 'POST',
url: BASEURL + 'index.php/invoice/InvoicesData/' + auth,
contentType: 'application/json; charset=utf-8',
data: ko.toJSON(string)
})
.done(function(invoices) {
self.invoicedatas.removeAll();
self.repaymentinvoicedatas.removeAll();
$.each(invoices, function (index, invoice) {
self.invoicedatas.push(new InvoiceViewModel(self, invoice));
self.repaymentinvoicedatas.push(new InvoiceViewModel(self, invoice));
});
// holds the total invoicedatas count
self.TotalNumberOfInvoicedatas(self.invoicedatas().length);
self.TotalNumberOfRepaymentInvoicedatas(self.repaymentinvoicedatas().length);
// initialize the invoicedatasintable observable from the invoicedatas observable
self.searchRepaymentInvoicedatas();
self.searchInvoicedatas();
/* If it's requested to display repayment invoice payment confirmation info, display it. */
if (self.displayModalInfo()) {
self.showModalPaymentConfirmation();
}
})
.fail(function(xhr, status, error) {
alert(status);
})
.always(function(data){
});
};
self.InitializeInvoiceViewModel();