2010-05-17 93 views
0

我在我的應用程序中有此代碼,但這不會加載任何數據。數據是可訪問的,但不會顯示在我的網格面板中,任何人都有想法,爲什麼?Extjs中的GridPanel未加載

Ext.onReady(function() { 
     Ext.QuickTips.init(); 
     Ext.form.Field.prototype.msgTarget = 'side'; 

     var btnAdd = new Ext.Button({ 
      id: 'btnAdd', 
      text: 'Adicionar', 
      iconCls: 'application_add', 
      handler: function (s) { 

      } 
     }); 
     var btnEdit = new Ext.Button({ 
      id: 'btnEdit', 
      text: 'Editar', 
      iconCls: 'application_edit', 
      handler: function (s) { 

      } 
     }); 
     var btnRemove = new Ext.Button({ 
      id: 'btnRemove', 
      text: 'Apagar', 
      iconCls: 'application_delete', 
      handler: function (s) { 

      } 
     }); 

     var tbar = new Ext.Toolbar({ 
      items: [btnAdd, btnEdit, btnRemove] 
     }); 

     var formFind = new Ext.FormPanel({    
      height: 100 
     }); 

     var store = new Ext.data.JsonStore({ 
      remoteSort: true, 
      idProperty: 'ContentId', 
      root: 'rows', 
      totalProperty: 'results', 
      fields: [ 
       { name: 'ContentId', type: 'int' }, 
       { name: 'Name' }, 
       { name: 'Version' }, 
       { name: 'State' }, 
       { name: 'CreatedDateTime' }, 
       { name: 'PublishedDateTime'}, 
       { name: 'CreatedByUser' }, 
       { name: 'PublishedByUser' } 
      ], 
      proxy: new Ext.data.ScriptTagProxy({ 
       url: '/Admin/ArticleList' 
      }) 
     }); 
     store.setDefaultSort('ContentId', 'desc'); 

     var paging = new Ext.PagingToolbar({ 
      store: store, 
      pageSize: 25, 
      displayInfo: true, 
      displayMsg: 'Foram encontrados {2} registos. Mostrando {0} de {1}', 
      emptyMsg: "Nenhum registo encontrado." 
     }); 

     var grid = new Ext.grid.GridPanel({ 
      id: 'grid', 
      height: 700, 
      store: store, 
      loadMask: true, 
      loadingText: 'Carregando...', 
      autoHeight: true, 
      cm: new Ext.grid.ColumnModel ([ 
       { id: 'ContentId', dataIndex: 'ContentId', header: 'Identif.', width: 60, sortable: true }, 
       { id: 'Name', dataIndex: 'Name', header: 'Titulo', width: 75, sortable: true }, 
       { id: 'Version', dataIndex: 'Version', header: 'Versão', width: 75, sortable: true }, 
       { id: 'State', dataIndex: 'State', header: 'Estado', width: 75, sortable: true }, 
       { id: 'CreatedDateTime', dataIndex: 'CreatedDateTime', header: 'Data de Criação', width: 85, sortable: true }, 
       { id: 'PublishedDateTime', dataIndex: 'PublishedDateTime', header: 'Data de Publicação', width: 75, sortable: true }, 
       { id: 'CreatedByUser', dataIndex: 'CreatedByUser', header: 'Criado por', width: 75, sortable: true }, 
       { id: 'PublishedByUser', dataIndex: 'PublishedByUser', header: 'Publicado por', width: 85, sortable: true } 
      ]), 
      stripeRows: true, 
      viewConfig: { forceFit: true }, 
      bbar: paging 
     }); 

     var panel = new Ext.Panel({ 
      id: 'panel', 
      renderTo: Ext.getBody(), 
      layout: 'fit', 
      tbar: tbar, 
      items: [grid] 
     }); 

     store.load(); // trigger the data store load 
    }); 
+0

當代碼執行後會發生什麼?網格渲染是否正確? – Tommi 2010-05-18 08:46:46

回答

1

您不應該使用ScriptTagProxy。如果您閱讀文檔,您會發現它僅在有限的情況下才能以特定格式從遠程服務器檢索上下文。

你想要一個HttpProxy。