PDA

View Full Version : [Solved] Removing item from list failing after the panel change.



blessan
30 Jul 2010, 2:24 AM
I have a list as an item for the nested list. I used as a substitute for the grid. Was able to style it and everything.
Each row in the list has has a delete icon on the right. When he clicks on it the row is removed. I was able to get this all done. I used the store.removeAt method to remove the row.
It all works fine in the beginning. Now when I switch to another panel in the nested list and come back to the panel with my list and try to delete again I get the following error.
'Cannot call method 'getCount' of null'

Can some one please help

this is my listener


listeners: {
"itemtap": function(dataview,index,element,evt) {
eventClassname = evt.target.className;;
if(eventClassname.search('deleteProduct')!= -1) {
dataview.store.removeAt(index);
}
}
}

blessan
30 Jul 2010, 11:03 PM
doesnt anyone face the same issue?

evant
30 Jul 2010, 11:24 PM
There isn't really enough information, though it seems like the store is somehow being destroyed.

blessan
31 Jul 2010, 1:26 AM
Heres my code. It has my store,model and list.
To run it. simply put
'giftPanel' as item for the the nested list. I still cant figure out whats going wrong.



Ext.regModel('gifts', {
fields: ['giftNumber', 'price','cls']
});

giftStore = new Ext.data.Store({
model: 'gifts',
data: [
{giftNumber: 'Total Gifts', price: '84.00', cls:'prodListHeader'},
{giftNumber: '756634', price: '84.00', cls:'prodListOdd'},
{giftNumber: '888565', price: '54.00', cls:'prodListEven'},
{giftNumber: '907357', price: '84.00', cls:'prodListOdd'},
{giftNumber: '128675', price: '54.00', cls:'prodListEven'},
{giftNumber: '234756', price: '84.00', cls:'prodListOdd'},
{giftNumber: '123456', price: '54.00', cls:'prodListEven'},
]
});

giftPanel = [
{
xtype: 'textfield',
name : 'giftNumber',
cls:'serviceSlt serviceTop clientName soapTop',
label: 'Gift Number'
},
{
cls:'clientName soapMiddle giftTo',
text: '<span class="giftToLabel">Tax</span><span class="soapAmount giftToText">Required</span>'
},
{
xtype: 'numberfield',
cls:'serviceSlt serviceBottom clientName soapMiddle',
name: 'giftPurchase',
label: 'Purchase',
minValue : 0
},
{
xtype: 'numberfield',
cls:'serviceSlt serviceBottom clientName soapMiddle',
name: 'giftValue',
label: 'Value',
minValue : 0
},
{
xtype: 'textfield',
name : 'giftExpires',
cls:'serviceSlt serviceTop clientName soapBottom',
label: 'Expires',
value:'01-08-10'
},
{
xtype:'panel',
cls:'addServicesList',
style:'height:100px',
html:'<span style="float:right;color:white;display:inline-block;width:150px;margin-top:10px;">'+
'<p>Total Sale: 0.00</p>'+
'<p>Payments: 0.00</p>'+
'<p>Balance Due: 0.00</p>'+
'</span>',
items:[
{
xtype: 'button',
//cls:'checkoutTicketButton checkoutAptButton',
width:100,
style:'display:inline-block;margin-top:20px;',
ui: 'normal',
text: 'Add',
handler: function() {
alert('add');
}
},
]
},
{
xtype: 'list',
store: giftStore,
tpl: '<tpl for="."><div class="gifts {cls}">'+
'<span class="listDelete deleteGifts">&nbsp;</span>'+
'<span class="listProduct listPayType">{giftNumber}</span>'+
'<span class="listDelete listPayAmount">{price}</span>'+
'</div></tpl>',
itemSelector: 'div.gifts',
singleSelect: true,
cls:'productList',
scroll:false,
listeners: {
"itemtap": function(dataview,index,element,evt) {
eventClassname = evt.target.className;
titleClassname = element.className;
if((eventClassname.search('deleteGifts')!= -1) &&(titleClassname.search('prodListHeader') == -1)) {
selectedRecord = dataview.store.getAt(index);
dataview.store.remove(selectedRecord);
}
}
}
}
];

blessan
1 Aug 2010, 7:57 PM
evant any clue whats goin wrong?

evant
1 Aug 2010, 8:03 PM
As I said above, it looks like the store is either being destroyed or set to null.

blessan
2 Aug 2010, 3:06 AM
any idea how to fix this. I tried to set the store every time i reach the particular panel in the listchange event but that also wont work.

blessan
2 Aug 2010, 9:45 PM
It works after I updated to v0.93. I really exhausted every trick I knew. Guess the bug fixes corrected everything.