admin管理员组

文章数量:1327849

I'm using a dgrid but find the documentation available from the website (/) a bit lacking: it teaches you the basics but seems to leave you to work out how to do anything more plex 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 bine 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

I'm using a dgrid but find the documentation available from the website (http://dojofoundation/packages/dgrid/) a bit lacking: it teaches you the basics but seems to leave you to work out how to do anything more plex 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 bine 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

Share Improve this question asked Aug 31, 2013 at 14:07 KateKate 1,5761 gold badge17 silver badges36 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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

var columns = [
  {
    label : ' ',
    field : 'plexCell',
    renderCell: function(object, value, node, options) {
      domHtml.set(node, object[propA] + ' (' + object[propB] + ')');
    }
  },
  ...
];

本文标签: javascriptdojo dgrid custom render cell contentsStack Overflow