PDA

View Full Version : Selecting records in a grid not working.



joao_candido
16 Jul 2009, 5:55 AM
I´ve got this grid:



grid.permissoes = new Ext.grid.GridPanel({
fieldLabel: "Permissões",
store: store.telas,
cm: new Ext.grid.ColumnModel([
new Ext.grid.CheckboxSelectionModel({
checkOnly: true,
sortable: true
}),
{header: "Tela", sortable: true, dataIndex: "tla_nome"}
]),
height: 150,
width: 300,
forceLayout: true,
view: new Ext.grid.GridView({
forceFit: true,
autoFill: true,
emptyText: "Nenhuma tela encontrada!"
})
})


So, I´m trying to run it:



grid.permissoes.getStore().each(function (record, item) {
if (record.data.tla_grupos.indexOf(grupo) >= 0) grid.permissoes.getSelectionModel().selectRow(item);
});
grid.permissoes.getView().refresh(true);


I tried to alert the isSelected of each record and it returns true, but in my grid the selected rows does not appears as selected.

joao_candido
16 Jul 2009, 6:01 AM
Another thing about this grid.

The header checkbox is not working for select/deselect all records.

MacSimon
13 Aug 2009, 7:07 AM
I'm having the same 2 problems, the checkOnly doesn't work and the header checkbox is not working eather.

Have you allready found a solution for these 2 issues?

Georgioa
14 Aug 2009, 1:31 AM
I'have the same problem.

1rt who find the solution have to post it ! ;)

Animal
14 Aug 2009, 1:41 AM
Explain your problem fully.

Remembering that loading data is asynchronous, and data will only be available to select after a few moments when the request has travelled to the server, the SQL query has run, been processed, and the returned data has travelled back to the browser, been processed there, and caused a GridView to update itself..

Only THEN can you select any data.

Georgioa
14 Aug 2009, 2:10 AM
Ok, this works for me now.

I retrive metaData and data from my server and load them in my grid.

So i have to put my CheckBoxSelectionModel first :



...
config.selModel = new Ext.grid.CheckboxSelectionModel();
OD.grid.RemoteDataGrid.superclass.constructor.call(this, config);
When my grid is rendered, I load data from server :



Ext.extend(OD.grid.RemoteDataGrid, Ext.grid.GridPanel, {
onRender : function(ct, position) {

this.colModel.defaultSortable = true;
OD.grid.RemoteDataGrid.superclass.onRender.call(this, ct, position);

this.el.mask(OD.lang.loading);
this.store.on('metachange', function() {
// Adding columns
if (typeof(this.store.reader.jsonData.columns) === 'object') {
var columns = [];
if (this.rowNumberer) {
columns.push(new Ext.grid.RowNumberer());
}
if (this.checkboxSelModel) {
columns.push(new Ext.grid.CheckboxSelectionModel());
//this.selModel = new Ext.grid.CheckboxSelectionModel({singleSelect : false});
}

Ext.each(this.store.reader.jsonData.columns, function(column) {
columns.push(column);
});
this.getColumnModel().setConfig(columns);
}
this.el.unmask();
},this);
}
}

But I don't understand why I have to define the CheckBoxSelectionModel two times, 1st in my config, and then in my column model.

Animal
14 Aug 2009, 3:34 AM
Because that first time, you are not putting it in as a column.