2015-02-06 61 views
0

我試圖刪除一些數組的記錄來顯示它,但是當我刪除記錄時,什麼都不刪除。如何從js中的數組中刪除記錄

Ext.onReady(function() {   
Ext.create('BVCore.Grid', { 
    id:'gridServiceCatalogAll', 
    renderTo: 'gridServiceCatalogAll', 
    stateId: 'gridServiceCatalogAll',  
    store: Ext.create('BVCore.LocalStore', { 
     fields: ['id','category', 'name', 'equipment', 'sizeMin', 'sizeMax', 'description', 'annualCharge'], 
     groupers:[grouper], 
     proxy: { 
      url: '<spring:url value="/controller/search/json/serviceCatAll.json" />'    
     }, 
     listeners:{ 
      load: function(store, records) { 
       Ext.each(records, function(record, index){ 
        Ext.each(records, function(rec, ind){ 
         if((record.get('category') == rec.get('category')) && (record.get('annualCharge') == rec.get('annualCharge')) && (record.get('id') != rec.get('id'))){ 
          store.remove(rec); 
         } 
        }, this); 
       }, this); 
      } 
     } 
    }), 
    features: [{ftype:'grouping'}], 
    columns: [ 
       {text: '<spring:message code="serviceModel.category" />', dataIndex: 'category'}, 
       {text: '<spring:message code="serviceModel.description" />', dataIndex: 'description'}, 
       {text: '<spring:message code="serviceModel.annualCharge" arguments="${year}" />', dataIndex: 'annualCharge'}      
      ] 
}); 

});

有人有什麼想法嗎?

+0

在什麼時候,你顯示它?你能發佈完整的代碼嗎? – atmd 2015-02-06 14:39:04

+0

@atmd我編輯我的帖子 – 2015-02-06 14:42:14

回答

0

似乎你想刪除一個對象的屬性,
這裏是你如何做到這一點。

var obj = {'foo':'bar'} 
delete obj.foo 
console.log(obj); //Object {} 
+0

我做了這個但沒有結果,但它進入下if – 2015-02-06 14:47:31