Breeze 你需要15分钟。我建议您从这里开始,并与您的代码进行比较,看看有什么不同。很好,luckI成功了:我需要引用viewModel变量中的invoice.lines,如下所示:vm.invoice().lines.valueHasMutated()。谢谢你抽出
Breeze 你需要15分钟。我建议您从这里开始,并与您的代码进行比较,看看有什么不同。很好,luckI成功了:我需要引用viewModel变量中的invoice.lines,如下所示:vm.invoice().lines.valueHasMutated()。谢谢你抽出,breeze,Breeze,你需要15分钟。我建议您从这里开始,并与您的代码进行比较,看看有什么不同。很好,luckI成功了:我需要引用viewModel变量中的invoice.lines,如下所示:vm.invoice().lines.valueHasMutated()。谢谢你抽出时间。 var getInvoiceById = function (invoiceId, invoiceObservable, forceRemote) { // Input: invoiceId: the id of the inv
你需要15分钟。我建议您从这里开始,并与您的代码进行比较,看看有什么不同。很好,luckI成功了:我需要引用viewModel变量中的invoice.lines,如下所示:
vm.invoice().lines.valueHasMutated()代码>。谢谢你抽出时间。
var getInvoiceById = function (invoiceId, invoiceObservable, forceRemote) {
// Input: invoiceId: the id of the invoice to retrieve
// Input: forceRemote: boolean to force the fetch from server
// Output: invoiceObservable: an observable filled with the invoice
if (forceRemote)
queryCacheInvoice = {};
var query = entityQuery.from('Invoices')
.where('id', '==', invoiceId)
.expand("Client, Client.Contacts, Lines")
.orderBy('Lines.Number');
var isInCache = queryCacheInvoice[invoiceId];
if (isInCache && !forceRemote) {
query = query.using(breeze.FetchStrategy.FromLocalCache);
} else {
queryCacheInvoice[invoiceId] = true;
query = query.using(breeze.FetchStrategy.FromServer);
}
return manager.executeQuery(query)
.then(querySucceeded)
.fail(queryFailed);
function querySucceeded(data) {
invoiceObservable(data.results[0]);
}
};
public class Invoice
{
[Key]
public int Id { get; set; }
public string Number { get; set; }
public DateTime? Date { get; set; }
public int? ClientId { get; set; }
public string Comment { get; set; }
public double? TotalExclVAT { get; set; }
public double? TotalInclVAT { get; set; }
public double? TotalVAT { get; set; }
public bool? WithoutVAT { get; set; }
public virtual List<InvoiceLine> Lines { get; set; }
public virtual Client Client { get; set; }
}
public class InvoiceLine
{
[Key]
public int Id { get; set; }
[Required]
public int Number { get; set; }
[Required]
public string Description { get; set; }
public int InvoiceId { get; set; }
public Invoice Invoice { get; set; }
}
<a href="#" data-bind="click: $parent.sortList">Sort</a>
var sortAscending = true;
var viewmodel = {
...
sortList: sortList,
...
};
...
function sortList(list) {
list.todos().sort(function(left, right) {
return (sortAscending ? 1 : -1) *
(left.title().toLowerCase() < right.title().toLowerCase() ? -1 : 1);
});
sortAscending = !sortAscending; // reverse sort direction
list.todos.valueHasMutated(); // let KO know that we've sorted
}