PDA

View Full Version : how set the textFeild show the grid default,not to click or dbclick the grid cell?



yatell
12 May 2011, 5:41 AM
code is follow:

JsonStore:
var dataStore=new Ext.data.JsonStore({
fields: ['condi_name','condi_field'],
autoLoad:true,
root:'data',
data:{'results':2,'data':[{'condi_name':'AREA,'condi_field':'area_code'},
{'condi_name':'TIME,'condi_field':'area_code'}]}
});

cm:
var checkSm=new Ext.grid.CheckboxSelectionModel();
var cm=new Ext.grid.ColumnModel([checkSm,new Ext.grid.RowNumberer(),{
header: "AAAA",
width: 150,
dataIndex:'condi_name',
renderer:function(value, metadata, record, rowIndex, colIndex, store){
return "<divid='condi_grid_cm_condi_name_"+rowIndex+"'></div>"
},{
header: "BBBB",
width: 150
}]);
grid:
var grid=new Ext.grid.EditorGridPanel({
id:'condi_grid_id',
renderTo: 'condi_grid_div',
store:dataStore,
cm:cm,
stripeRows:true,
viewConfig: {
forceFit: true
},
listeners:{
viewready:function(grid){
for(var i=0;i<grid.getStore().data.length;i++){
new Ext.form.TextField({
allowBlank:false,
renderTo:'condi_grid_cm_condi_name_'+i,
width:120
})
}
}
},bbar:[{
text: 'add',
iconCls:'icon-add-record',
width:60,
handler: function(){
var record = new Ext.data.Record({
condi_name:'test',
condi_field:'',
condi_showType:1
});
grid.stopEditing();
dataStore.insert(dataStore.getCount(),record);
grid.startEditing(dataStore.getCount()-1,0);
grid.getView().refresh();
},{
text: 'delete',
iconCls:'icon-delete-record',
width:60,
handler:function(){
var rsm = grid.getSelectionModel();
var view = grid.getView();
var store = grid.getStore();
for(var i = view.getRows().length - 1; i >= 0 ; i --){
if(rsm.isSelected(i)){
store.remove(store.getAt(i));
}
}
view.refresh();
}
}],
autoShow:true,
selModel:checkSm,
loadMask: true,
height: 140
});

event:
dataStore.addListener('add',function(store){
alert('add');
new Ext.form.TextField({
allowBlank:false,
renderTo:'condi_grid_cm_condi_name_'+store.data.length-1,
width:120
})
});
dataStore.addListener('update',function(store){
alert('update');
dataStore.addListener('remove',function(store){
alert('remove')
});
});


When I click Add ,but the cell not show the textField,
why?

friend
12 May 2011, 6:28 AM
Comment out grid.getView().refresh() and see what you get...