Code:
Ext.require([
'Ext.data.*',
'Ext.grid.*',
'Ext.toolbar.Paging',
'Ext.Util.*',
'Ext.picker.*',
'Ext.window.*',
'Ext.tip.*',
'Ext.form.*',
'Ext.EventObject',
'Ext.data.StoreManager',
'Ext.util.DelayedTask',
'Ext.view.BoundList',
'Ext.view.BoundListKeyNav'
]);
Ext.onReady(pageInitialize);
function pageInitialize(){
Ext.define('HedgeModel',{
extend:'Ext.data.Model',
fields:[
{name:'accountsubtype',type:"string"},
{name:'accountNumber',type:"string"}
]
});
hedgeStore=Ext.create('Ext.data.Store',{
model:'HedgeModel',
storeId:'HedgeStore'
});
var cellEditing=Ext.create('Ext.grid.plugin.CellEditing',{
clicksToEdit:1
});
var grid=Ext.create('Ext.grid.Panel',{
store:hedgeStore,
columns: [{
header:'Account Type',
dataIndex:'accountsubtype',
width:130,
editor: new Ext.form.field.ComboBox({
typeAhead:true,
triggerAction:'all',
editable:true,
selectOnTab:true,
store:['Shade','Share'],
lazyRender:true,
listClass:'x-combo-list-small'
})
},{
id:'accountNum',
header:'Account Number',
dataIndex:'accountNumber',
flex:1,
editor:{
allowBlank:false
}
},{
xtype:'actioncolumn',
width:30,
sortable:false,
items:[{
icon:'../resources/images/delete.png',
tooltip:'Delete Row',
handler: function(grid,rowIndex,colIndex)
{
hedgeStore.removeAt(rowIndex);
}
}]
}],
selModel:{
selType:'cellmodel'
},
renderTo:'resultGrid',
width:600,
height:300,
title:'Add Accounts To This Template',
frame:true,
tbar:[{
text:'Add Account',
handler: function(){
alert("Function Started");
var r=Ext.create('HedgeModel',{
accountsubtype:'Share',
accountNumber:''
});
alert("Record created");
hedgeStore.insert(0,r);
alert("Record inserted");
cellEditing.startEditByPosition({row:0,column:0});
}
}],
plugins:[cellEditing]
});
}