2012-01-05 76 views
0

我想做一个简单的请求,如Ext.Ajax.request并将其显示在列表中。但它不起作用。Ext.Ajax.request Sencha Touch

我有这样一个URL

http://server/GetContacts.aspx?CustAccount=10019

谁能告诉我它是如何工作的,什么我应该考虑?

这是我回来的例子。

{ 
    "HasError": false, 
    "ErrorString": "", 
    "Data": [ 
    {"ContactPersonId":"","Name":"","FirstName":"","MiddleName":"","LastName":"","Phone":"","CellularPhone":"","Telefax":"","Email":"","Url":"","Address":"","ZipCode":"","City":"","Street":"","Country":"","Function":""} 
    ] 
} 

回答

0
Ext.regModel('kunden', { 
        idProperty: 'id', 
        fields: [ 
         { name: 'ContactPersonId', type: 'string' }, 
         . 
         . 
         . 

         { name: 'Function', type: 'string' } 

        ] 
       }); 

       Ext.regStore('kundenStore', { 
        model: 'kunden', 
        sorters: [{ 
         property: 'LastName' 
        }], 

        proxy: { 
         type: 'ajax', 
         url: 'http://server/GetContacts.aspx?CustAccount=10019' 
        }, 
        reader: { 
         type: 'json', 
         root: 'Data' 
        } 
       }); 
NotesApp.views.kundenList = new Ext.List({ 
        id: 'kundenList', 
        store: 'kundenStore', 
        grouped: true, 
        indexBar : true, 
        itemTpl: '<div class="list-item-title">{firstname} {lastname}</div>' +'<div class="list-item-narrative">{email}</div>', 
        listeners: {} 
        } 
       }); 

它可以如此轻易XP