简体   繁体   English

更新整个dojox.grid.datagrid行

[英]Updating entire dojox.grid.datagrid row

I've been trying to update the entire row of my grid, but having issues. 我一直在尝试更新网格的整个行,但是遇到了问题。 I am able to update a single cell (if it doesn't have a formatter), but I would like to be able to update the entire row. 能够更新某一个单元(如果它没有格式化),但我想能够更新整个行。 Alternatively, I could update the column, but I'm not able to get it working if it has a formatter. 另外,我可以更新该列,但是如果它具有格式化程序,则无法使它工作。

Here is the code that I'm using to update the grid: 这是我用来更新网格的代码:

grid.store.fetch({query : { some_input : o.some_input },
    onItem : function (item ) {
        dataStore.setValue(item, 'input', '123'); //works!
        dataStore.setValue(item, '_item', o);     //doesn't work!
    }
});

And the structure of my grid: 以及我的网格的结构:

structure: [
    { type: "dojox.grid._CheckBoxSelector"},
    [[{ name: "Field1", field: "input", width:"25%"}
     ,{ name: "Field2", field: "another_input", width:"25%"}
     ,{ name: "Field3", field: "_item", formatter:myFormatter, width:"25%"}
     ,{ name: "Field4", field: "_item", formatter:myOtherFormatter, width:"25%"}
    ]]
]

Got some information in the #dojo freenode channel from 'tk' who kindly put together a fiddle showing the proper way to do this, most noteably putting an idProperty on the memoryStore and overwriting the data: http://jsfiddle.net/few3k7b8/2/ 从#tjo的#dojo freenode频道中获得了一些信息,他们将“ tk”放到了一个小提琴中,以显示执行此操作的正确方法,最值得注意的是,将idProperty放置在memoryStore上并覆盖了数据: http : //jsfiddle.net/few3k7b8/ 2 /

    var memoryStore = new Memory({
      data: [{
         alienPop: 320000,
         humanPop: 56000,
         planet: 'Zoron'
      }, {
         alienPop: 980940,
         humanPop: 56052,
         planet: 'Gaxula'
      }, {
         alienPop: 200,
         humanPop: 500,
         planet: 'Reiutsink'
      }],
      idProperty: "planet"
    });

And then when we want to update: 然后,当我们要更新时:

    memoryStore.put(item, {
        overwrite: true
    });

Remember that item has to have a field 'planet', and it should be the same as one of our existing planets in order to overwrite that row. 请记住,该项目必须有一个“行星”场,并且它应与我们现有的行星之一相同,以便覆盖该行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM