SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 295 forks source link

Grid should accept async renderCell functions #139

Open AllNamesRTaken opened 12 years ago

AllNamesRTaken commented 12 years ago

It would help immensely if the grid would accept renderCell functions that return deferreds. Then we could maybe have async rendering of components in the grid.

this code in Grid.js

}else if(column.renderCell){ // A column can provide a renderCell method to do its own DOM manipulation, // event handling, etc. appendIfNode(td, column.renderCell(object, data, td, options));

could maybe be something like:

}else if(column.renderCell){ cell = column.renderCell(object, data, td, options); if(cell.then) cell.then(function(node) { appendIfNode(td, node); }); else // A column can provide a renderCell method to do its own DOM manipulation, // event handling, etc. appendIfNode(td, cell);

And of course the same in the other places where renderCell or renderHeadercell is used.

//J

AllNamesRTaken commented 12 years ago

Same for Editor.js. Instead of having a synchronous function that creates the editor using the new keyword and expecting that to set up the domNode and get all dependencies synchronously, we could be allowed to supply an async function that returns an instance of the widget (or widget-like class) in its promise. The the rest of the wiring could proceed as normal.

This would allow things such as IoC instanciation of controls with dependency injection.

//J

mikerobi commented 12 years ago

In my application, a very small percentage of cells are very expensive to compute, rendering them asynchronously will significantly decrease the load time of the rest of the grid.

However, I am not convinced that this needs to be built in to the dgrid. My original plan was to have renderCell insert a loading indicator and generate a closure that will be used to asynchronously update the cell.

PunkChameleon commented 10 years ago

:+1: Any news on this? It'd be great to be able to use deferred objects in formatter or renderCell

Lumina83 commented 10 years ago

Yeah that would be great. I am updating from Dojo 1.6 to 1.9 and want to use dgrid now. We are working a lot with deferred Objects and now I can't use my old formatter-functions in the new dgrid. :-(