PDA

View Full Version : grouping / rowactions and empty groups



EducatedFool
6 Mar 2009, 4:10 AM
Hello,

I'm having a grid with groups. Problem, when I got a group with no items, it's showing the group (that's what I want), but it's also giving one empty row. Makes the view a little bit ugly (look at attachment). I don't know if this is cause I'm using rowactions in my grid. Anyone a sollution?



// the store

resultsDataStore =

new Ext.data.GroupingStore({

id : 'resultsDataStore',
proxy : new Ext.data.HttpProxy({
url : webroot+module+'/'+controller+'/index/',
method : 'GET'
}),
groupField : 'werknemer_id',
baseParams : {json: "1"},
reader : new Ext.data.JsonReader({
root : 'results',
totalProperty : 'total',
id : 'id'
}, dataRecord),
groupOnSort : false,
remoteGroup : true,
remoteSort : true
});


// row actions
var rowAction = new Ext.ux.grid.RowActions({
header : 'Actions',
autoWidth : false,
actions : [
{ iconCls: 'edit', tooltip: 'Regel bewerken' },
{ iconCls: 'delete', tooltip: 'Regel verwijderen' }
],
groupActions:[
{ iconCls : 'add', tooltip: 'Regel toevoegen' }
],
callbacks:{
'edit':function(grid, record, action, row, col) {
onRegelAddClick({value: 'edit'},null);
},
'delete':function(grid, record, action, row, col) {
onDeleteClick();
},
'add':function(grid, records, action, groupId) {
onRegelAddClick({value:'add'},records[0].data["werknemer_id"]);
}
}
});


// groupingview
groupingview =


new Ext.grid.GroupingView({

showGroupName : false,
enableNoGroups : false,
hideGroupedColumn : true,
groupTextTpl : '({[values.rs[0].data["afd"]]}) {[values.rs[0].data["werknemer"]]}',
forceFit : true
});
var summary = new Ext.grid.GroupSummary();


resultsColumnModel =


new Ext.grid.ColumnModel([

expander,
{ header : '#', dataIndex : 'id', hidden : true },
{ header : 'werknemer_id', dataIndex : 'werknemer_id' },
{ header : '', width : 20, renderer: colorRenderer },
{ header : 'project', dataIndex : 'projectcode', width : 70, renderer: projectRenderer },
{ header : 'projectleider', dataIndex : 'projectleider', width : 85, summaryRenderer: function() { return'totaal :';} },
{ header : 'ma', dataIndex : 'maandag', width : 25, align: 'right', renderer: floatRenderer, summaryType:'sum' },
{ header : 'di', dataIndex : 'dinsdag', width : 25, align: 'right', renderer: floatRenderer, summaryType:'sum' },
{ header : 'wo', dataIndex : 'woensdag', width : 25, align: 'right', renderer: floatRenderer, summaryType:'sum' },
{ header : 'do', dataIndex : 'donderdag', width : 25, align: 'right', renderer: floatRenderer, summaryType:'sum' },
{ header : 'vr', dataIndex : 'vrijdag', width : 25, align: 'right', renderer: floatRenderer, summaryType:'sum' },
{ header : 'za', dataIndex : 'zaterdag', width : 25, align: 'right', renderer: floatRenderer, summaryType:'sum' },
{ header : 'zo', dataIndex : 'zondag', width : 25, align: 'right', renderer: floatRenderer, summaryType:'sum' },
{ header : 'tot', dataIndex : 'tot', width : 25, align: 'right', renderer: totRenderer, summaryType:'sum' },
{ header : 'goedkeuren', dataIndex : 'goedgekeurd', width : 70, renderer: goedgekeurdRenderer, editor: dropStatus },
rowAction
]);


resultsListingGrid =


new Ext.grid.EditorGridPanel({

id : 'resultsListingGrid',
store : resultsDataStore,
view : groupingview,
plugins : [expander,summary,rowAction],
cm : resultsColumnModel,
enableColLock : false,
title : 'Urenverantwoording',
height : 525,
stripeRows : true,
collapsible : false,
animCollapse : false,
autoWidth : true,
selModel : new Ext.grid.RowSelectionModel({singleSelect:true}),
tbar : [],
clicksToEdit : 1,
listeners: {
validateedit: function(e) {
switch(e.field) {
case"goedgekeurd":
var combo = resultsListingGrid.getColumnModel().getCellEditor(e.column, e.row).field;
e.record.set('goedgekeurd', combo.getRawValue());
break;
}
}
}
});