]>
git.proxmox.com Git - extjs.git/blob - extjs/build/examples/classic/feed-viewer/viewer/FeedGrid.js
1 Ext
.define('FeedViewer.FeedGrid', {
2 extend
: 'Ext.grid.Panel',
4 alias
: 'widget.feedgrid',
8 * Fires when a row is double clicked
9 * @param {FeedViewer.FeedGrid} this
10 * @param {Ext.data.Model} model
15 * Fires when a grid row is selected
16 * @param {FeedViewer.FeedGrid} this
17 * @param {Ext.data.Model} model
20 initComponent: function(){
23 store
: Ext
.create('Ext.data.Store', {
31 url
: 'feed-proxy.php',
37 exception
: this.onProxyException
,
52 bodyField
: 'description',
57 itemdblclick
: this.onRowDblClick
64 renderer
: this.formatTitle
74 renderer
: this.formatDate
,
78 this.callParent(arguments
);
79 this.on('selectionchange', this.onSelect
, this);
83 * Reacts to a double click
85 * @param {Object} view The view
86 * @param {Object} index The row index
88 onRowDblClick: function(view
, record
, item
, index
, e
) {
89 this.fireEvent('rowdblclick', this, this.store
.getAt(index
));
94 * React to a grid item being selected
96 * @param {Ext.model.Selection} model The selection model
97 * @param {Array} selections An array of selections
99 onSelect: function(model
, selections
){
100 var selected
= selections
[0];
102 this.fireEvent('select', this, selected
);
107 * Listens for the store loading
110 onLoad: function(store
, records
, success
) {
111 if (this.getStore().getCount()) {
112 this.getSelectionModel().select(0);
117 * Listen for proxy eerrors.
119 onProxyException: function(proxy
, response
, operation
) {
120 Ext
.Msg
.alert("Error with data from server", operation
.error
);
121 this.view
.el
.update('');
123 // Update the detail view with a dummy empty record
124 this.fireEvent('select', this, {data
:{}});
128 * Instructs the grid to load a new feed
129 * @param {String} url The url to load
131 loadFeed: function(url
){
132 var store
= this.store
;
134 store
.getProxy().setExtraParam('feed', url
);
142 formatTitle: function(value
, p
, record
){
143 return Ext
.String
.format('<div class="topic"><b>{0}</b><span class="author">{1}</span></div>', value
, record
.get('author') || "Unknown");
150 formatDate: function(date
){
155 var now
= new Date(), d
= Ext
.Date
.clearTime(now
, true), notime
= Ext
.Date
.clearTime(date
, true).getTime();
157 if (notime
=== d
.getTime()) {
158 return 'Today ' + Ext
.Date
.format(date
, 'g:i a');
161 d
= Ext
.Date
.add(d
, 'd', -6);
162 if (d
.getTime() <= notime
) {
163 return Ext
.Date
.format(date
, 'D g:i a');
165 return Ext
.Date
.format(date
, 'Y/m/d g:i a');