Ordering sequence plugin assign class
Ordering sequence plugin assign class
Is there an easy way to allow the developer to assign a class for orderNumbers? I know the default is dt-order-number, but for some DataTables I would like to define the class to be dt-order-number-top when the DataTable has multiple rows for a header. I would then define the css for dt-order-number-top
Otherwise the default class dt-order-number will be used.
Instead of:
orderNumbers: true
Something like:
orderNumbers: {className: 'dt-order-number-top'}
This question has accepted answers - jump to:
Answers
Not at the moment - it is hard coded without a configuration option I'm afraid.
Good idea for an enhancement though, I'd happy take a PR for that.
Allan
I will attempt a PR, haven't done one in a while
Trying to look through other code to see how you handled additional settings for a feature. Couldn't find any in my quick search.
Not sure if this is the standard you are looking for:
Original Code:
Modified code:
I have also made a similar change to the
function draw(table) {}
init()
will get you the initialisation object without needing to hit the settings object. It'd be worth adding a check fororderNumbers
being defined on the object as well before using it, but aside from that, yeah, I think looks good - nice one.Allan
Got it so like:
If this is general what you are looking for, I will try to put together a pull request.
Is there any documentation I need to take care of?
I could also post a comment to your blog about the feature and the change made.
I see in the init.dt the feature is enabled based on settings or defaults.
var enable = settings.oInit.orderNumbers || DataTable.defaults.orderNumbers;
Do I need to worry about defaults when checking for the className?
For completeness you could add a bit about the default. You'd need to make a default object available though:
I'd take the PR with or without that to be honest.
Documentation - currently no. That is something I really need to sort out for the plugins. Possibly adding an example showing the option in use would be the way to do it at the moment.
Allan
I couldn't find code in any other feature for the above recommendation for completeness. So I will let you educate me by adding it.
I would be happy to add an example but need to determine how to in the orderNumbers/examples folder.
Thanks for the PR! I've made this commit to allow the defaults to work with an object based initialisation, and also add an example.
Allan
Sorry I couldn't make the correct changes to add the new option, causing you to refactor. I will definitely used this plug-in as an example for any future PRs.
Thanks for the inclusion of the new option.
What Plugin category are you going to add this to?
No worries - the plugins are constantly evolving and this one probably has better default handling than the others now. I'll be using it as a template as well!
Its a feature plugin, which again is an evolving part of the site. I need to spend some time working on the documentation and presentation of the plugins.
Allan