PDA

View Full Version : Facing problems while doing multiple add records. Any solutions?



rakshyas
9 Apr 2013, 11:16 AM
I am new to the coding and ExtJS and am also facing problems with this topic.
I have an array of records and need to perform multiple inserts into the datastore.
I am using the following code snippet under the save button for adding records:

if (selectionValue==2){
console.log("step 1");
for (i=0; i<areaArray.length; i++){
storeVendor.beginEdit();
storeVendor.set("store_number",parseInt(areaArray[i]));
storeVendor.set("vendor_number",Ext.getCmp("vendorPicker").getValue());
app.storeToVendorStore.add(storeVendor);
storeVendor.commit();
}
storeVendor.endEdit();
app.storeToVendorStore.save();
Ext.getCmp("storeVendorsWindow").destroy();
app.storeToVendorStore.reload();
}

The array has 12 records right now. This code gets the job done..but Firefox repeatedly keeps on giving the warning message "Unresponsive script. A scripton the script may be busy, or....." . i have to hit continue multiple times before all the records are added.

Any solutions or advice as to why this might be happening?

mtpillai
9 Apr 2013, 11:16 PM
in one of my screen i have done the same with code given below. have a look the same


var myData =[]

Ext.define('Company', {
extend: 'Ext.data.Model',
fields: ['Item','Qty'],
idProperty: 'Item'
});
i have created and initilize array with empty values, so initialy it ll e empty.
var gridStore = Ext.create('Ext.data.ArrayStore', {
model: 'Company',
data: myData
});


for (i=0; i<areaArray.length; i++){
myData.push([parseInt(areaArray[i],,Ext.getCmp("vendorPicker").getValue()]);
}
gridStore.loadData(myData,false);
gridStore.reload();



try it:=D>