2012-03-01 41 views
2

我開發ASP prorject在視圖中使用extjs。我有問題在EXTJS中使用ItemSelector。無法在ItemSelector中顯示Selected Item EXTJS 3

這是我的代碼:

var isForm = new Ext.Panel({ 
    fieldLabel: 'Role', 
    width: 700, 
    bodyStyle: 'padding:10px;', 
    store: GroupStore, 
    //renderTo: 'itemselector', 
    items: [   
    { 
     xtype: 'itemselector', 
     name: 'itemselector', 
     fieldLabel: 'ItemSelector', 
     imagePath: '../../ExtResources/ux/images/', 
     multiselects: [{ 
      legend: 'Available', 
      width: 250, 
      height: 200, 
      store: GroupStore, 
      displayField: 'groupName', 
      valueField: 'groupID' 
     } 
     , { 
      legend: 'Selected', 
      width: 250, 
      height: 200, 
      store: [['','']] 
     }] 
    }] 
}); 

,這是我的商店:

var GroupStore = new Ext.data.JsonStore({ 
    remoteSort: true, 
    root: 'data', 
    //autoLoad: loadStore2, 
    autoLoad: true, 
    totalProperty: 'totalCount', 
    idProperty: 'groupID', 
    fields: [{ 
     name: 'groupID' 
    }, { 
     name: 'groupName' 
    }], 
    proxy: new Ext.data.HttpProxy({ 
     //url: 'InputUserLoadHandler.ashx?get=groups&comp=HSO' 
     url: 'InputUserLoadHandler.ashx?get=groups' 
    }) 
}); 

在 '選定' 列不能顯示其已經選擇的項目。 我曾嘗試在「可用」列和「已選」中使用我的商店,但結果是已在雙方都顯示的項目。

this是reffrence我ItemSelector 請給我解決這個問題的解決方案......

回答

0

您設置窗體的商店屬性。這是不正確的。嘗試在商品選擇器中設置商店。

+0

我應該在哪裏放置商店?當我把它放入物品時,它被錯誤地反駁。消息是「對象爲空」 你能告訴我應該在哪裏放?感謝innerJL – indi60 2012-03-07 04:20:54

+0

商店的數據格式給這個錯誤帶來了什麼影響? – indi60 2012-03-07 04:29:04

+0

你可以發佈你的例子嗎?在jsfiddle例如?通過代碼很難說清楚。例如,您可以用簡單的數據陣列替換您的ajax數據。使用Json可以使用 – 2012-03-07 06:12:16

0

我是從數據庫重新加載數據,我的項目使用Json來緩衝數據。 companystore的格式數據是這樣的:

{ "totalCount":"4", "data":[ 
    { 
    "groupID": 1, 
    "groupName": "Receiving" 
    }, 
    { 
    "groupID": 2, 
    "groupName": "Checking" 
    }, 
    { 
    "groupID": 3, 
    "groupName": "Shipment & Packing" 
    }, 
    { 
    "groupID": 4, 
    "groupName": "Display Stock" 
    } 
] } 

是否可以使用ItemSelector?在sencha示例中使用數組。