PDA

View Full Version : Empty rows inside a grid



Erwan62
27 May 2009, 1:17 AM
Hi everybody,

I read on the forum that we can insert empty rows in a grid that uses a GroupingView to avoid the empty groups to disappear when there are no items inside.

I found a sample of code that is supposed to insert this empty line in my grid :


// Création de la grille

var grid = new Ext.grid.GridPanel({
id : 'grid_gp',
store : ds,
cm : colModel,
sm : sm,
view : new Ext.grid.GroupingView({
showGroupName : false,
forceFit : true,
groupTextTpl : '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "membres" : "membre"]})'
}),
listeners: {
render: {
fn: function(grid){
var groups = grid.view.getGroups();
var ds = grid.getStore();
var lastId = ds.data.keys[ds.data.keys.length-1];

for (var i = 0; i < groups.length; i++)
{
var lastRowOfGroup = grid.view.findLastRowOfGroup(Ext.get(groups[i])) ;
var r = ds.getAt(lastRowOfGroup).copy();
r.data.fake = true;
r.id = ++lastId;
ds.insert(lastRowOfGroup, r);
}
},
scope: this
}
},
enableDrag: true,
autoHeight : true,
width : 1404,
frame : true,
stripeRows: true,
tbar : [
{
text : 'Ajouter',
tooltip : 'Ajouter un groupe',
iconCls : 'add',
handler : fct_add
},
'-',
{
text : 'Modifier',
tooltip : 'Modifier un groupe',
iconCls : 'update'
},
'-',
{
text : 'Supprimer',
tooltip : 'Supprimer un groupe',
iconCls : 'remove'
}
]
});

grid.view.getRowClass = function(row, index)
{
if (row.data.fake)
return 'x-grid-group-body-hide';
}

// Afichage de la grille

grid.render(document.getElementById('grille_groupes'));

ds.load(); // Chargement du datastoreBut it doesn't work, the groups still disappear when I delete all the items...

Anobody who knows why ?

Erwan62
27 May 2009, 6:17 AM
Some help please :)

Erwan62
27 May 2009, 11:25 PM
It's hard to get some help on this forum...

Erwan62
29 May 2009, 4:30 AM
Up, please...

moegal
29 May 2009, 2:51 PM
Erwan62,

Sorry I cannot help. The forum has been really helpful for me. I am sure someone will lend a hand soon.

Marty

Erwan62
31 May 2009, 11:13 PM
I hope :S