我在弹出窗口上有一个extjs网格,当弹出窗口打开时,它必须显示一行并选中并聚焦。它没有第一次显示选中但是如果我关闭弹出窗口并再次打开它就会完美无缺。
function CreateClientGrid()
{
if ( clientGrid === null )
{
var grid_inp,
columns = [], column,
index, i =0;
var clienttype = $('#clienttype').val();
if(clienttype == 1)
{
grid_data = GetAffiliateGridData();
}
else if(clienttype == 0)
{
grid_data = GetClientGridData();
}
else if(clienttype == 2)
{
grid_data = GetAdvertiserGridData();
}
$( "#client_grid" ).keydown(function(e)
{
var ret = KeyCheck ( e, clientGrid );
return ( ret );
});
// Prepare columns for grid
for ( index in grid_data.keys )
{
column = {
text : grid_data['values'][index],
dataIndex : grid_data['keys'][index]['name'],
flex : 1,
sortable : true,
editor : {
allowBlank : true
}
};
columns[i++] = column;
}
grid_inp = {
renderTo: 'client-grid',
frame: true,
id: 'clientGrid',
autoScroll: true,
width: 375,
height: 228,
plugins: {
ptype: 'bufferedrenderer',
trailingBufferZone: 40, // Keep 40 rows rendered in the table behind scroll
leadingBufferZone: 80 // Keep 80 rows rendered in the table ahead of scroll
},
viewConfig: {
stripeRows: true
},
selType: 'rowmodel',
store: affiliateStore,
columns: columns,
columnLines: true,
autoScroll: true,
dockedItems: []
};
clientGrid = Ext.create('Ext.ux.LiveSearchGridPanel', grid_inp );
if(Number(selected)!= 0)
{
console.log(selected);
clientGrid.getSelectionModel().select(Number(selected));
clientGrid.getView().focusRow(Number(selected),800);
//clientGrid.getPlugin('bufferedrenderer').scrollTo(20);
}
}
if(Number(selected)!= 0)
{
console.log(selected);
clientGrid.getSelectionModel().select(Number(selected));
clientGrid.getView().focusRow(Number(selected),800);
//clientGrid.getPlugin('bufferedrenderer').scrollTo(20);
}
// Clear the search field in the grid toolbar
clientGrid.down('textfield[name=searchField]').setValue('');
}
问题和解决方案是什么?