我想显示一个带有 JsonStore 服务器端的 extjs 组合,我使用 python/Django。
所以,这是我的组合:
xtype: 'combo',
store: new Ext.data.JsonStore({
url: 'get_peoples',
root: 'data',
totalProperty: 'total',
fields: [
{name: 'name', mapping: 'fields.name'},
{name: 'subname', mapping: 'fields.subname'}
],
autoLoad: true
}),
trigerAction: 'all'
和 views.py 服务器端:
def get_peoples(request):
queryset = People.objects.all()
data = '{"total": %s, "%s": %s}' % \
(queryset.count(), 'data', serializers.serialize('json', queryset))
return HttpResponse(data, mimetype='application/json')
get_people 打电话给我
{"total": 1, "data": [{"pk": 1, "model": "myapp.people", "fields": {"name": "Paul", "subname": "Di Anno"}}
我认为我做的不对,因为我的组合没有显示任何项目