2016-03-31 13 views
0

Backgrid'in Client-Side filtre uzantısıyla arama yaparken koleksiyonumdan doğru totalRecords değerini almada sorun yaşıyorum.Backgrid İstemci-Side aramasındaki toplam satırlar nasıl elde edilir

Klavyemde arka boşluk tuşunu kullandığımda. (?)

O totalRows gibi görünüyor
//Search input field - keyup event 
$("input[name='q']").keyup(function() { 

    console.log('searchcontainer input - keyup event'); 
    console.log($(this).val()) 
    console.log($(this).val().length) 

    var key = event.keyCode || event.charCode; 
    if (key == 8) { //'8' == backspace key 
     console.log('backspace was keyed!') 

     //how do I refresh the 'totalRecords' property on the collection? 
    } 

    console.log((_myCollection.state.totalRecords || "0") + " records found.")); 

    $("#lblRecordsFound").text((_myCollection.state.totalRecords || "0") + " records found."); 
}); 

bir geri al ateşlendiğinde bir koleksiyon güncelleştirme atlar:

Ben backspace kullanın ve yavaş yavaş yazmazsanız

, bu iyi çalışıyor gibi görünüyor?

Backspace kullanırken mevcut toplam sayıları nasıl alabilirim? Koleksiyonu sıfırlamak, getirmek veya yenilemek zorunda mıyım? Emin değilim. Yardım et?

Sadece kılavuzda şu anda görüntülenen toplam sayılara ihtiyacım var.

cevap

0

Backgrid-filter.js uzantısını "değiştirerek" bitirdim.

Öyle gibi arama işlevini değişmiş:

/** 
    Takes the query from the search box, constructs a matcher with it and 
    loops through collection looking for matches. Reset the given collection 
    when all the matches have been found. 

    If the collection is a PageableCollection, searching will go back to the 
    first page. 
*/ 
search: function() { 
    var matcher = _.bind(this.makeMatcher(this.query()), this); 
    var col = this.collection; 
    if (col.pageableCollection) col.pageableCollection.getFirstPage({ silent: true }); 
    col.reset(this.shadowCollection.filter(matcher), { reindex: false }); 
    var message = " items found."; 
    if (col.pageableCollection.state.totalRecords == 1) { 
     message = " item found."; 
    } 
    $("#lblRecordsFound").text((col.pageableCollection.state.totalRecords || "0") + message); 
}, 

iyi çalışır. Backgrid'in neden geçerli toplam satırlara kolay erişim için açık bir mülkiyeti olmadığını anlamıyorum.

İlgili konular