PDA

View Full Version : Preselecting a list view



ta4ka
1 Mar 2011, 3:44 AM
Hello i am trying to preselect a listview on load but can't seem to do it. With comboboxes I just loaded the store and used the setValue method. But here it doesn't exist. I have tried with the .value field alos but still nothing.

this is my store:
var storeSeries = new Ext.data.ArrayStore({
id: 1,
fields: ['color', 'name', 'ploted'],
data: []
});

My listview:

{
xtype: 'listview',
id: 'lvSeriesSelector',
store: storeSeries,
//multiSelect: false,
emptyText: 'No series to display',
hideHeaders: true,
singleSelect: true,
value: lvSeriesSelectorValue,
//reserveScrollOffset: true,
columns: [

{
header: 'Color',
width: .1,
dataIndex: 'color'
},
{
header: 'Name',
width: .35,
dataIndex: 'name'
},
{
header: 'Ploted',
dataIndex: 'ploted',
align: 'right'
}],
listeners: {
scope: this,
'click': lvSeriesSelectorHandler
}
},

mberrie
13 May 2011, 1:13 AM
Stumbled upon this while migrating my ListView. So for the archives (since its 2 months old)

Ext.list.ListView is no more, use a Ext.grid.Panel instead.

Things worth considering:


ListView used a ColumnLayout with percentage for widths, the Ext4 grid panel uses a BoxLayout (supports absolute widths like '50px' and relative widths via 'flex'



To select an entry programmatically, use #getSelectionModel().select(record) or similar. To mimic the behavior of ListView use the default Row(Selection)Model and selectByPosition({ row: 0}) for the first row



If you used a custom render template on your ListView's column definition via the tpl property, you have to make this column a xtype : 'templatecolumn', or use the 'renderer' config options for columns. see http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.grid.column.Column.html


hth