mleibman / SlickGrid

A lightning fast JavaScript grid/spreadsheet
http://wiki.github.com/mleibman/SlickGrid
MIT License
6.82k stars 1.98k forks source link

Support of several grids #1077

Open yvvan opened 9 years ago

yvvan commented 9 years ago

Currently I need to keep the list of grids to be able to access them. Also some methods should contain grid as a parameter to be able to identify where they belong, for example: getFormatter() or filter(items[i], args) example: 1) for my filter i need dataView to know which filter is it and take proper data function TreeFilter(item, args, dataView) { var parent = dataView.getItemById(item.parent); } 2) for my formatter i need grid to be passed as an argument because it's important for behavior function TreeFormatter (row, cell, value, columnDef, dataContext, grid) { //set behavior by grid data };

6pac commented 9 years ago

I agree, this is something that needs to be tweaked. The current code often relies on closures or grid-specific functions, which can be clunky in a multi-grid scenario. Over at my 'alternate master' repo, I've put together some multi-grid sample pages, but I haven't got around to making this change. Perhaps in the next week.

6pac commented 9 years ago

OK, in the alternate master I have just committed the following:

For the DataView filter function I'd argue that the DataView object should just be added as a member of the args object. For the grid editor function template, the grid is already a parameter.

yvvan commented 9 years ago

in slick.grid.js i currently use stringArray.push(getFormatter(row, m)(row, cell, value, m, item, self)); instead of stringArray.push(getFormatter(row, m)(row, cell, value, m, item)); because I have no other way to get other grid parameters - for example I don't have data to compare the rows hierarchy in tree (as in example http://mleibman.github.io/SlickGrid/examples/example5-collapsing.html )

6pac commented 9 years ago

I believe that's what I've just done. bullet point number 2. I haven't tagged and release it yet, it's just the latest commit to the repo