PDA

View Full Version : GroupingStore without displaying grid column



geewhizbang
7 Aug 2009, 5:08 PM
I have two issues with the following code

I don't want to display the grouped column, but if I leave it out it crashes
I have more than one row of data being returned, but only one shows up in the Grouping Store


function ForumInit()
{
if (typeof(KnowledgeBase.gridForumList) != "undefined") return;
Ext.select('div[box^=t]').boxWrap();
Ext.ns('KnowledgeBase.Forum');

KnowledgeBase.Forum.Renderers =
{
Forum : function(value, p, r)
{
return String.format
(
'<div class="SD_CellTitleLink"><a onclick="javascript:alert(\'selected ForumId: {2}\')">{0}</a></div><div class="SD_CellText">{1}</div>',
value, 'Some description text not yet in the data goes here',
r.data.ForumID
);
},
LastPost : function(value, p, r)
{
return String.format
(
'<div class="SD_CellTitleLink CB"><a onclick="javascript:alert(\'selected ThreadId: {0}\')">{1}</a></div><div class="SD_CellText FL"><span class="SD_lbl">by</span> {2}</div><div class="SD_CellDate">{3}</div>',
value, r.data.LastPostTopic, r.data.LastPostBy, r.data.LastPostDate.dateFormat('g:i a M j, Y')
);
}
};
KnowledgeBase.Forum.ForumListStore = new Ext.data.GroupingStore
(
{
proxy: new Ext.data.DirectProxy
(
{
paramsAsHash: false,
directFn: DirectRequest.GetForumView
}
),
autoLoad: true,
groupField:'CatName',
sortInfo: { field: 'CatName', direction: 'ASC' },
remoteSort:false,
reader: new Ext.data.JsonReader
(
{
idProperty: 'ForumID',
fields:
[
{name: 'ForumID', type: 'string'},
{name: 'ForumName', type: 'string'},
{name: 'CreatedBy', type: 'string'},
{name: 'CreatedDate', type: 'date'},
{name: 'ForumType', type: 'string'},
{name: 'NumberOfPosts', type: 'int'},
{name: 'NumberOfThreads', type: 'int'},
{name: 'CatId', type: 'int'},
{name: 'CatName', type: 'string'},
{name: 'ModifiedBy', type: 'string'},
{name: 'ModifiedDate', type: 'date'},
{name: 'LastPostBy', type: 'string'},
{name: 'LastPostThreadId', type: 'int'},
{name: 'LastPostTopic', type: 'string'},
{name: 'LastPostDate', type: 'date'}
],
remoteSort: false
}
)
}
);
KnowledgeBase.gridForumList = new Ext.grid.GridPanel
(
{
renderTo: 'divForum',
frame: false,
viewConfig: { autoFill: true },
stripeRows: false,
scroll: false,
autoHeight:true,
autoWidth:true,
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
store: KnowledgeBase.Forum.ForumListStore,
columns:
[
{header: "Category", width:100, sortable: true, dataIndex: 'CatName'},
{header: 'Forum', id:'ForumColumn', dataIndex:'ForumName', renderer: KnowledgeBase.Forum.Renderers.Forum, sortable: false},
{header: 'Last Post', dataIndex:'LastPostThreadId', renderer: KnowledgeBase.Forum.Renderers.LastPost, width:240, sortable: false},
{header: 'Posts', dataIndex:'NumberOfPosts', width: 90, sortable: false}

],
view: new Ext.grid.GroupingView
(
{
forceFit:true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
}
)
}
);
}

geewhizbang
7 Aug 2009, 5:25 PM
I have confirmed that I am getting two records back, since this alert gives me "Loaded 2 records".

However, only one displays.



listeners:
{
load: function(s, records)
{
Ext.MessageBox.alert("Information", "Loaded " + records.length + " records");
}
},

geewhizbang
7 Aug 2009, 5:54 PM
I've figured out #1: I can make the column hidden.


But I inexplicably only have one row displayed despite two of them in the data.

geewhizbang
8 Aug 2009, 9:44 AM
I have finally solved this problem, too. The server was returning incorrect data, with the rowIDs all the same instead of unique rows.