Question

I'm using a dgrid but find the documentation available from the website (http://dojofoundation.org/packages/dgrid/) a bit lacking: it teaches you the basics but seems to leave you to work out how to do anything more complex by guesswork.

Specifically, I want to modify how the data I've loaded into a memory store is rendered. For example, I'd actually like to combine two columns from the store into one column in the grid with some additional text. Obviously one way would be to create a second memory store, iterate the first store and build the exact contents the dgrid should show in the second store. However, that feels clunky and like having to have two sets of the same data, just differently formated.

I can see there are renderRow and renderCell methods. Can anyone give me examples of how to use these, or point me to some documentation?

Thanks, Simon

Was it helpful?

Solution

The renderCell function gives you the data object, so you can build the cell using any properties from the data.

var columns = [
  {
    label : ' ',
    field : 'complexCell',
    renderCell: function(object, value, node, options) {
      domHtml.set(node, object[propA] + ' (' + object[propB] + ')');
    }
  },
  ...
];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top