0

我正在试验 Dojo,对使用 Django/tastypie 实现的 REST 服务使用 DataGrid/JsonRestStore。

似乎 JsonRestStore 期望数据以纯数组的形式到达,而 sweetpie 在包含“模式”和“对象”的结构中返回数据集。

{
  "meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1}, 
  "objects": [{...}]
}

所以,我需要以某种方式附加到“对象”部分。

实现这一目标的最明智的方法是什么?

  • 奥文德
4

2 回答 2

1

Untested, but you might try creating a custom store that inherits from JsonRestStore and override the internal _processResults method. It's a two-liner in the Dojo 1.7 code base, so you can implement you own behavior quite simply.

_processResults: function(results, deferred){
    var count = results.objects.length;
    return {totalCount: deferred.fullLength || (deferred.request.count == count ? (deferred.request.start || 0) + count * 2 : count), items: results.objects};
}

See lines 414-417 of the dojox/data/JsonRestStore.js for reference.

于 2012-08-13T21:30:05.860 回答
0

我不知道这是否对你有帮助。http://jayapal-d.blogspot.in/2009/08/dojo-datagrid-with-editable-cells-in.html

于 2012-08-13T13:26:37.807 回答