【问题标题】:Can't display Selected Item in ItemSelector EXTJS 3无法在 ItemSelector EXTJS 3 中显示所选项目
【发布时间】:2012-03-01 04:40:16
【问题描述】:

我在视图中使用 extjs 开发 ASP 项目。我在 EXTJS 中使用 ItemSelector 时遇到问题。

这是我的代码:

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 是我的 ItemSelector 的引用 请给我解决这个问题的方法...

【问题讨论】:

    标签: c# javascript .net extjs asp-classic


    【解决方案1】:

    您设置了表单的 store 属性。这是不正确的。尝试在你的 itemselector 中设置 store。

    【讨论】:

    • 我应该把商店放在哪里?当我把它放入物品中时,它被错误地反击了。消息是“对象为空”你能告诉我应该把它放在哪里吗?谢谢innerJL
    • 你能把你的例子贴在某个地方吗?例如在jsfiddle?仅通过代码很难分辨。例如,您可以用简单的数据数组替换您的 ajax 数据。
    • 可以使用Json吗?因为我的项目中没有使用数组而是使用 Json。感谢您的回答innerJL
    【解决方案2】:

    我正在从数据库中重新加载数据,我的项目使用 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 示例中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      相关资源
      最近更新 更多