PDA

View Full Version : Empty an array



chandan.behura
2 Sep 2012, 4:23 AM
How to make empty to an array inside a function?

See the highlighted parts in my code.


onShow : function() {
var max = this.getPopupStoreStore().getCount();
Ext.select('.x-mask').addListener('click', function() {
var yourSelection = myView.getComponent('Shipping Condition');
//alert(grid);
//alert(yourSelection);
var resultString = "";
var selected = [];
var selection = grid.getSelectionModel().getSelection();

for ( var i = 0; i < selection.length; i++) {
console.log(selection[i].data.all);
selected.push(selection[i].data.all); //How to make 'selected' variable empty before pushing values again. Or Any other way to acieve thae same.
}

console.log(selected);

popUp.hide();
});

}

vietits
2 Sep 2012, 3:55 PM
Try this


for ( var i = 0; i < selection.length; i++) {
console.log(selection[i].data.all);
selected = []; // or Ext.Array.erase(selected, 0, seletecd.length);
selected.push(selection[i].data.all); //How to make 'selected' variable empty before pushing values again. Or Any other way to acieve thae same.
}