简体   繁体   中英

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/

    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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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