fin-hypergrid / core

A canvas-based super high performant grid renderer API
MIT License
897 stars 144 forks source link

Multi-line text content in cells #495

Closed jjrv closed 7 years ago

jjrv commented 7 years ago

Would it be possible to have line breaks in cell text content? The corresponding row would have to grow in height, possibly making different rows have different heights.

It seems this is currently only supported for the header row?

Dwaynekj commented 7 years ago

You can extend your own renderer from Simple Cell to allow this to occur in dataCells

jjrv commented 7 years ago

The issue is that the renderer gets config.bounds.height but I'd need to first set up a hook that checks how many lines of text there are in that cell and computes the pixel height of the row (which should get cached somewhere). Otherwise the renderer will just draw outside its given bounds on top of something else.

Dwaynekj commented 7 years ago

@jjrv I won't be able to provide an update this week. This item might involve some leg work. We can plan on it for next sprint. Are you open to doing some investigation yourself?

I will be able to address your tree-view concerns

jjrv commented 7 years ago

In theory I'm open to work on this, but not sure when there's time. Lots of ongoing projects at the moment. More likely I'll be able to read code and figure out how it could work, than actually writing new code. A hook is needed to give the measurements for a cell, and there's implications for scrolling... The scrollbar should probably work in terms of rows, since before preparing to actually render you can't know the height of any row.

jjrv commented 7 years ago

If you switch to TypeScript, it will be a LOT easier for external developers to understand the internal workings and make this sort of changes.

joneit commented 7 years ago

Juha, regarding implementing line breaks, some thoughts...

We are not interested in adding features to our general cell renderer, SimpleCell.js. It is already doing a lot and we never really wanted "one cell renderer to rule them all" because cell renderers above all need to be performant. Therefore, if you have a cell that has a special need (such as being able to show line breaks), I strongly suggest setting just that cell's (or that column's) cell renderer to a custom cell renderer.

Basic cell renderers are simple to write. Doing so suffers mainly from lack of a wiki. We will be addressing that deficit in the current sprint.

Looking at cellRenderers/SimpleCell.js you can see that we have a method renderMultiLineText that actually does text wrapping. (This method is restricted by SimpleCell to header cells. The reason for this restriction is that it is non-performant and should be avoided for data cells.)

Use renderMultiLineText as an example... Your need is much much simpler.

Basically:

Caveats:

There are many strategies that can be employed as an alternative to the expensive clipping. For example, we previously had column clipping in the grid renderer itself, much better performance than clipping for every cell individually, but this proved to be a general performance drag and we commented it out. Our new grid renderers have designs with varying types of clipping, but all are commented out. We will consider reenabling them as an option in 1.3.1.

Note that cell renderers are instanced once (as singletons) for the each grid instance and thereafter referred to by name.

On Fri, Feb 10, 2017 at 3:36 AM, Juha Järvi notifications@github.com wrote:

If you switch to TypeScript, it will be a LOT easier for external developers to understand the internal workings and make this sort of changes.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openfin/fin-hypergrid/issues/495#issuecomment-278887131, or mute the thread https://github.com/notifications/unsubscribe-auth/AFt_EBlRdxqsFdCQlptT-MaynxOlVMI8ks5rbCGagaJpZM4L5L5c .

-- Jonathan Eiten Senior Developer | OpenFin 201-674-1457 jonathan@openfin.co

Build Once. Deploy Instantly. Run Natively. www.openfin.co | @openfintech

Skype: jonaverse Twitter: @JonathanEiten LinkedIn: http://www.linkedin.com/in/jonathaneiten http://www.linkedin.com/in/jonathaneiten