代码如下:
queryTree = SC.Query.local('Tree.Category',
"categoryId = {categoryId}", {
categoryId: this.get('guid'),
orderBy: "name ASC"
});
queryNote = SC.Query.local('Tree.Note',
"categoryId = {categoryId}", {
categoryId: this.get('guid'),
orderBy: "name ASC"
});
var arrayCategory = Tree.store.find(queryTree);
var arrayNote = Tree.store.find(queryNote);
//Concatenate arrayCategory to arrayNote我想返回一个新的记录数组,将结果附加到arrayCategory和arrayNote。我浏览了文档,但似乎没有连接函数。
发布于 2012-12-08 02:42:59
我想我必须将这两个搜索结果连接起来。但是我这样解决了这个问题:对于Tree.Note和Tree.Category中的每个记录,我创建了一个名为isChild的字段,并将其设置为前者的YES和后者的NO。此外,我将函数的返回值更改为:
return Tree.store.find(SC.Query.local(['Tree.Category','Tree.Note'],
"categoryId = {categoryId}", {
categoryId: this.get('guid'),
orderBy: 'isChild, name',
}))编辑:还是有些地方不对劲。有人能建议应该如何改变这一点吗?
发布于 2012-12-07 15:54:22
这应该可以很好地工作:
var result = Tree.store.find(SC.Query.local([Tree.Category, Tree.Note],
"categoryId = {categoryId}", {
categoryId: this.get('guid'),
orderBy: "name ASC"
}));要连接两个数组,您可以使用pushObjects方法,但它不能处理SC.Query的结果,因为它返回一个不可编辑的SC.RecordArray (因为它会在您添加或删除记录时自动更新)。
https://stackoverflow.com/questions/13739900
复制相似问题