dimanche 4 mai 2014

store: sorters does not seem to work

for an app, based on the First App in the documentation Guides, i'm trying to sort the feed list by date. it goes like this:

(app.js)



Code:



Ext.application({
...
launch: function() {
...
Ext.create('Ext.tab.Panel', {
fullscreen: true,
tabBarPosition: 'bottom',

items: [
...
{
xtype: 'nestedlist',
title: 'Agenda',
iconCls: 'calendar',
displayField: '{sortDate} - {title}',

getItemTextTpl: function(node) {
return this.getDisplayField();
},

store: {
fields: [
'title', 'link', 'content', 'contentSnippet', 'publishedDate',
{
name: 'sortDate',
convert: function(value, record) {
var sDate = record.get('publishedDate'),
oDate = new Date(sDate);
console.log(typeof sDate);
console.log(typeof oDate);
return oDate;
},
type: 'date',
dateFormat: 'Y-m-d'
},
{name: 'leaf', defaultValue: true}
],

proxy: {
type: 'jsonp',
url: 'http://ift.tt/1lWwTdv',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
},

root: {
leaf: false
},

sorters: {
property: 'sortDate',
direction: 'ASC'
},

type: 'tree'
},
...
}
...

i created an extra field 'sortDate', converted from 'publishedDate' (string) and made sure it is a date object: 'console.log(typeof oDate);' prints: object.

my incoming feed entries are more or less ordered by date (most recent first), but not exactly or reliably: some items are in the wrong position. i expected...



Code:



...
sorters: {
property: 'sortDate',
direction: 'DESC'
},
...

...to re-sort the list by publishedDate, latest entry first.

this is not working as expected: the list is always in the same - unsorted/ proxy source - order, no matter if i sort ascending or descending, or even by 'title' instead of date. 'dateFormat' is also ignored; dates are displayed in IETF/ RFC 2822 format, like "Wed Apr 30 2014 16:56:00 GMT+0200 (W. Europe Daylight Time)", instead of "2014-04-30".


this problem occurs in chrome on windows, with the development version of the app via apache (testing, production and package builds were not tested). this app is packaged before with phonegap build, so all requests to index.html generate an error: "GET http://localhost/<appName>/phonegap.js 404 (Not Found) development.js:9.


i also tried typecasting 'publishedDate' directly to a date object, and use that for sorting:



Code:



{name: 'publishedDate', type: 'date', dateFormat: 'Y-m-d'}

without success.

note that i replaced the feed i'm really using with the SenchaBlog feed from the First App, in this post. your entries show exactly the same problem when i try to change their descending (proxy source) order to ascending.


context: windows 7 and xp pro, google chrome version 34.0.1847.131 m, sencha touch 2.3.1a.


please let me know if you need additional info.





Aucun commentaire:

Enregistrer un commentaire