-
-
Notifications
You must be signed in to change notification settings - Fork 444
advanced rendering #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hello devs, anybody who wants to review this? |
Conflicts: js/core/core.constructor.js js/core/core.data.js
Sorry - I thought I had responded to this at the time - apparently not! I'm a little bogged down at the moment with a number of other things, so I can't review at the moment, but I will try to as soon as I can. Allan |
Hello Allan, are you still bogged down? Kind regards |
Hi - yes I'm really sorry I haven't been able to pull this in yet. However, I've not forgotten about it - when I get the time to move on to the next major version of DataTables I hope to introduce this feature then and I'll be using ideas from here. |
And do you have any concrete plans when this is going to happen? ;) |
Nope. I truly wish I did - but the amount of time that support takes up is just phenomenal. It makes planning anything very difficult and thus I'm not giving out any more dates. |
Understood. ;) |
The lack of unit tests in DataTables, which I am working to resolve now. I hope it won't be a year as well - I'll be very disappointed if it is. |
That point is true indeed... However, the unit tests were already broken and outdated when a posted this one and a half years ago. (I know because I tried to use them for testing my implementation again. ;)) |
Because I felt it had potentially larger impact. I realise you are disappointed. So am I. I truly wish I had more time and I very much appreciate your taking the time to send the PR. I am working as much as is possible on all of this! It is proving to be difficult to balance everything. I can say that I hope to include something along these lines in future. I can't say it will be 100% compatible, but more advanced rendering will be in the next major version. |
Well, regarding the impact you're potentially right 😆 I wouldn't be so annoying if it wouldn't matter to me. |
This patch tries to introduce "advanced rendering" into DataTables.
"Advanced" is meant to express that the (display) render function is not limited to just returning the new content of a table cell, but rather change (render) the table cell directly.
This includes classes, css style and - of course - the content of the cell.
This is realized by using the call() function to execute the render function in the context of the table cell, e.g. "this" refers to the rendered cell.
Example:
Old code to color cells with different css classes depending on their data:
used by the respective column with
Findings:
Realizing this functionality with the new render algorithm is very easy and doesn't require any dirty fixes:
used in the column (note the absence of the "createdCell" callback) with
I tried to design this patch as much backwards compatible as possible, using
Additional things:
I had to introduce a new (fifth) render type (besides "display", "sort", "filter" and "type"), called "adjust". This renderer is used for the automatic width calculation.
Since the original implementation just removes markup tags from the return value of the display render function and uses the pure text for width approximation
it should not be necessary to define the "adjust" renderer in most of the cases.
Compatibility: If "newCellRender" is not "true", "adjust" is not used and the implementation falls back to the old behaviour, using "display" as its source.