View Full Version : storeX - storeY ?
neerajnandwana
03-24-2008, 06:16 PM
hi
i am trying something like that:
StoreZ= StoreX-StoreY
i want to remove all the record from StoreX which is in StoreY and rest record i want to assign to StoreZ.
Can anyone help me :-|
Thanks in advance
Neeraj
neerajnandwana
03-25-2008, 10:52 AM
Can we use the filter to solve this?
But how?
mjlecomte
03-25-2008, 12:31 PM
Sounds easier to implement server side with some kind of join?
If you can't do that post some code that you're working with. Your question is too vague to make suggestions on I think. You have records, remove them from one store and add them to another store. How you're going to implement that depends on your business logic, no?
neerajnandwana
03-25-2008, 06:14 PM
I am implementing the itemselector.
items:[{
xtype:"itemselector",
id: "itemSelectorID",
name:"itemSelector",
hiddenName:"itemSelector",
fieldLabel:"ItemSelector",
dataFields:["id", "display"],
mode:"local",
toStore: xStore,
fromStore: yStore,
msWidth:370,
msHeight:225,
valueField:"id",
displayField:"display",
toLegend:"Assigned",
fromLegend:"Available",
stripe:true
}]
where xStore and yStore
var xStore = new Ext.data.Store({
reader : jsonReader,
autoLoad : true,
proxy : new Ext.data.HttpProxy({
url : 'loadXStore.action'
})
});
var yStore = new Ext.data.Store({
reader : jsonReader,
autoLoad : true,
proxy : new Ext.data.HttpProxy({
url : 'loadYStore.action'
})
});
And i want to remove all record from yStore which is present in XStore.
Thanks for your reply mjlecomte :)
evant
03-25-2008, 06:51 PM
I don't really see how this is a problem? Loop through each record in X, compare it against each record in Y, fill a store with the difference.
neerajnandwana
03-27-2008, 07:28 PM
I am trying like this but it gives some error -B[A] has no properties
var xStore = new Ext.data.Store({
reader : jsonReader,
autoLoad : true,
proxy : new Ext.data.HttpProxy({
url : 'loadXStore.action'
})
});
var yStore = new Ext.data.Store({
reader : jsonReader,
autoLoad : true,
proxy : new Ext.data.HttpProxy({
url : 'loadYStore.action'
}),
listeners:{
load :{fn:function(thisStore,option){
for(var i=1;i<this.getTotalCount();i++){
xStore.remove(this.getAt(i));//ERROR-B[A] has no properties
}
}}
}
});
mjlecomte
03-27-2008, 08:16 PM
are you use ext-all-debug.js so you can inspect errors easier?
did you inspect via firebug to see what xstore is inside that function?
Looks like a scope problem to me.
Also looks like you should make sure xstore is loaded before operating on it.
var yStore = new Ext.data.Store({
reader : jsonReader,
autoLoad : true,
proxy : new Ext.data.HttpProxy({
url : 'loadYStore.action'
}),
listeners:{
load :{fn:function(thisStore,option){
console.log('inside load listener, xStore = ', xStore);//undefined?
for(var i=1;i<this.getTotalCount();i++){
xStore.remove(this.getAt(i));//ERROR-B[A] has no properties
}
}}
}
});
neerajnandwana
03-27-2008, 08:42 PM
I think it is trying to find the startIndex and endIndex but these store i am using in Multiselect box mean no startIndex and endIndex.
ext-all-debug.js
.......
updateIndexes : function(startIndex, endIndex){
var ns = this.all.elements;
startIndex = startIndex || 0;
endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
for(var i = startIndex; i <= endIndex; i++){
ns[i].viewIndex = i;//ERROR-ns[i] has no properties
}
},
.........
can we not remove the record through this way?
And what should be the alternative way to remove the record?
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.