英特尔XDK的ListView排序 [英] Intel XDK listview sort
问题描述
我试图让与英特尔XDK和Parse.com一个简单的应用程序作为后端服务。
I try to make a simple application with Intel XDK and Parse.com as backend service.
我做了如此列表视图教程显示。
ListView控件,在我的应用程序,显示在底部的最新项。代替的,我想显示与相反的方式列表。 - 在列表顶部的最新的条目
The listview, in my app, displays the newest entries at the bottom. Instead of that i want to show the list with the opposite way - the most recent entries at the top of the list.
在一个简单的HTML5的JS文件我做到这一点与 query.ascending(createdAt);在Parse.com在文档中描述的JavaScript
。我怎么能与英特尔XDK愿意这样做?
In a simple HTML5-JS file i do it with query.ascending("createdAt");
as described in documentation for JavaScript in Parse.com. How i can do it so with Intel XDK?
我将AP preciate每一个乐于助人的答案。
I will appreciate every helpfull answer.
修改克里斯 - 帕金斯的第一个答案后
EDIT after the first answer from Chris Perkins
我设法我Parse.com数据库英特尔XDK外部Web服务按照整合<一个href=\"http://stackoverflow.com/questions/25630215/intel-xdk-parse-com-integration-unauthorized/25650442#25650442\">this回答。
I managed to integrate my Parse.com database in Intel XDK as external web service according to this answer.
所以,在----- / WWW / XDK /服务/服务methods.js,通过我的服务调用的方法的一部分,是这样的:
So, in -----/www/xdk/services/service-methods.js, the part of method invoked by my service looks like this:
intel.xdk.services.iodocs_.New_Service = ((function (credentials) {
var exports = {};
exports.ServiceObject = function(params) {
var url = 'https://api.parse.com/1/classes/ServiceObject';
return $.ajax({
url : url,
headers : {
'X-Parse-Application-Id' : credentials.apiKey,
'X-Parse-REST-API-Key' : credentials.apiSecret
}
});
};
return exports;
}))(intel.xdk.services.credentials.New_Service,intel.xdk.services.iodocs_.helpers);
如果我有正确理解,我要反向显示阵列是我服务的回应身体的成果的价值,这一切都是 VAR出口的大括号内= { };
。我正确与否?
If I have understood correctly the array that i want to display reversely is the value of the "results" in the Respond Body of my service and all this is within the curly brackets of var exports = {};
. I am right or not?
推荐答案
我尝试了上述建议是什么,但甚至没有创建的列表。
I tried what suggested above, but the list was not even created.
的解决方案是不是数据库与应用程序相关联的方式。
The solution was not the way the database associated with the application.
我意识到,在一个模板和解决方案在于Backbone.js的文件中创建列表。所以,我打开了----- / WWW / JS / backbone_support.js,并试图通过做一些类似的
I realized that the list is created in a template and that the solution lies in the backbone.js file. So, i opened the -----/www/js/backbone_support.js and tried to intervene by doing something similar to this
var myCollection = Backbone.Collection.extend({
model: myModel,
comparator: function(item) {
return -item.get('');
}
});
或想找个地方一个符合这样的事情
or to find somewhere a line with something like this
$('#名单)追加(listItem.render()EL);
并修改 .append()
到。prePEND()
。
没有什么帮助了我。但最终我发现在code的那些行
Nothing helped me. But eventually I noticed those lines in the code
//non-destructive reverse
var nd_reverse = function(arr){ return _.initial(arr, 0).reverse(); };
我删除了 .reverse()
和它发生了。现在,列表显示在顶部我Parse.com数据库的最新作品。
I deleted the .reverse()
and it happened. Now the list displays the newest entries of my Parse.com database at the top.
我不知道这是否是propper的解决方案,或者如果它是适用于更复杂的问题,但我希望能帮助弄好了。
I don't know if this is the propper solution or if it is suitable for more complex issues but i hope to help somehow.
这篇关于英特尔XDK的ListView排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!