【问题标题】:ComboBox not working in datagrid组合框在数据网格中不起作用
【发布时间】:2012-01-28 16:21:38
【问题描述】:

我遗漏了一些非常基本的东西,我的组合框永远不会出现,有人可以看看下面的代码并告诉我我遗漏了什么,我已经尝试了 .Select 和 ComboBox 作为类型,我使用 dojo-1.5

var layout4 = 
[
{ field: "abbr", name: "Abbreviation", width: 10 },
{ field: "name", name: "Name", width: 10 },
{ field: "capital", name: "Capital", width: '10'},
{ field: "combo", name: "combo", width: 10,
  type: dojox.grid.cells.Select, 
  options: [ "new", "read", "replied" ],
  editable:true
}

];

var store4 =   { identifier: 'abbr',
 label: 'name',
 items: [
{ abbr:'ec', name:'Ecuador',           capital:'Quito', combo:'' },
{ abbr:'eg', name:'Egypt',             capital:'Cairo', combo:''},
{ abbr:'sv', name:'El Salvador',       capital:'San Salvador', combo:''},
{ abbr:'gq', name:'Equatorial Guinea', capital:'Malabo', combo:''},
{ abbr:'er', name:'Eritrea',           capital:'Asmara', combo:'' },
{ abbr:'ee', name:'Estonia',           capital:'Tallinn', combo:''},
{ abbr:'et', name:'Ethiopia',          capital:'Addis Ababa', combo:'' }
  ]};

storeData =  new dojo.data.ItemFileReadStore(
            { data:store4}
        ); 
    // create a new grid:
    var grid4 = new dojox.grid.DataGrid({
        query: { abbr: '*' },
        store: storeData,
        clientSort: true,
        rowSelector: '20px',
        structure: layout4
    }, document.createElement('div'));

    // append the new grid to the div "gridContainer4":
    dojo.byId("gridContainer4").appendChild(grid4.domNode);

    // Call startup, in order to render the grid:
    grid4.startup();

【问题讨论】:

    标签: datagrid dojo widget


    【解决方案1】:

    尝试用这个替换你使用appendChild() 的长行:

    grid4.placeAt("gridContainer4");
    

    您的代码相当混乱,没有看到整个事情,调试起来有点困难。您在控制台上收到任何错误吗?你能在JSFiddle上发布一个完整的例子吗?

    【讨论】:

    • jsfiddle.net/nRMrA/17 这是我第一次使用 jsfiddle,我粘贴在那里,什么都没有显示,但你可以看代码!请注意,当我在浏览器中运行网格时,它会正确显示,只是组合框部分不起作用!
    【解决方案2】:

    原因是我正在使用 ItemFileReadStore,并且不允许编辑商店中的项目,因此没有出现组合框。在这里使用 WriteStore 解决了这个问题。当然,使用 readsotre 是愚蠢的。

    现在我有一个不同的问题,我希望组合框出现在实现 canEdit 的网格中,但这是一个不同的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多