Customizing the HTML generated by DataTables

Customizing the HTML generated by DataTables

tomas_eklundtomas_eklund Posts: 14Questions: 1Answers: 0
edited January 2013 in Feature requests
I see that this might already be planned for version 1.11 but I just want to make sure we're on the same page by explaining what I would like to see in a future DataTables version. On the "Roadmap" page it says:
[quote]Renderers - the modules included in DataTables core will provide customisable renderers and post rendering hooks, for where HTML is output, allowing complete customisation of the controls. [/quote]
This sounds great. One thing I miss in DataTables right now is the ability to add HTML "wrappers" around the individual pagination controls, for example. As of now they are rendered something like:
[code]1
2
3...[/code]
While this is clean and functional HTML, it makes it harder to style the pagination "buttons" with the "sliding doors" technique (which requires the nodes to be wrapped in dual nested HTML elements). Also, since the pagination control could be viewed as a list of pagination commands it would make sense to wrap them in an unordered list element, like so:
[code]
1
2
3
...
[/code]
In essence, I'm really looking forward to being able to customize the HTML that DataTables generate, without hacking the core or writing a custom plugin for it (which I've found to be really hard!).

Replies

  • allanallan Posts: 55,108Questions: 1Answers: 8,653 Site admin
    That is very much the idea. In fairness, DataTables 1.11 probably won't be until the end of this year, but very simple tempting such as:

    [code]

    {loop}
    {i}
    {/loop}

    [/code]

    is likely how I'll do it. Each component will have its own parameters that must be included ( `{i}` in the above example).

    Until then, yes it is plug-ins that need to be used, and the paging plug-ins can be a little bit of a pig to get right! I might use the pagination as a trial for how the templates will work before integrating it into the core in 1.11.

    Regards,
    Allan
This discussion has been closed.