Note that there are some explanatory texts on larger screens.

plurals
  1. POExtjs grid and local store creates duplicates in grid while store is updated
    text
    copied!<p>I've a small grid with a local store and every time I'm updating data in that store, the record is updated in the store but the updated record is added in the grid instead of replacing the old one.</p> <p>Grid:</p> <pre><code>Highlights: Ext.create('Ext.grid.GridPanel',{ store:Ext.create('Ext.data.Store', { fields: [ {name: 'id', type: 'string'}, {name: 'QUANTITY', type: 'int'}, {name: 'HIGHLIGHT', type: 'string'}, {name: 'ICON', type:'string'}, {name: 'PRIORITY', type:'int'}, {name: 'GROUPICON', type:'string'}, ], sorters:['PRIORITY','QUANTITY'], data : [] }), hideHeaders:true, columns:[{ header:'Icon', dataIndex:'ICON', width:22, stateId:'ICON', renderer:function(val){ if(val != ''){ return '&lt;img src=icons/cq/'+val+'.png align=absmiddle border=0&gt;'; }else{ return ''; } } },{ header: 'Quantity', dataIndex: 'QUANTITY', stateId:'QUANTITY', width:35, align:'right', sortable: true, hidden: false },{ header: 'Highlight', dataIndex: 'HIGHLIGHT', stateId:'HIGHLIGHT', renderer:function(val){ return '&lt;b&gt;'+val+'&lt;/b&gt;'; }, flex:1, sortable: true, hidden: false },{ header:'Group Icon', dataIndex:'GROUPICON', width:28, stateId:'GROUPICON', renderer:function(val){ if(val != ''){ return '&lt;img src=icons/cq/'+val+'.png align=absmiddle border=0&gt;'; }else{ return ''; } } }], title:'I have...', iconCls:'topic', padding:'0 0 8 0' }) </code></pre> <p>Adding /updating a record:</p> <pre><code> Highlight:function(store,id,highlight,icon,priority,groupicon){ //SET VALUES if(typeof icon == 'undefined'){ var icon = '';} if(typeof priority == 'undefined'){ var priority = 9;} var quantity = store.data.length; //ADD / UPDATE if(quantity&gt;0){ this.Grids.Highlights.getStore().add({PRIORITY:priority,ICON:icon,GROUPICON:groupicon,QUANTITY:quantity,HIGHLIGHT:highlight,id:id}); } } </code></pre> <p>As you can see there is an "id" field and the id is correctly used by Extjs to update the store.</p> <p>if I trigger 3 times the same 'add()' to the store, I get 3 identical rows in the Grid while having still only one record in the store.</p> <p>Why?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload