Search code examples
tabulator

Tabulator.info: combine custom and built-in formatters?


I am using a custom formatter callback to highlight keywords in a text column. But I also want the full text displayed in the cell, i.e. wrapped, just like the built-in formatter 'textarea' does.

Is there a way to use both custom and built-in formatters?


Solution

  • You can only apply once formatter to any given cell, in your case the best approach would be to tweak your custom formatter to add the text area formatters functionality.

    Which will be as simple as adding this line of code to your custom formatter:

    cell.getElement().style.whiteSpace = "pre-wrap";
    

    If you are using a formatter that may result in the contents being of variable height then you will also need to set the variableHeight property in that columns definition to ensure the rows render correctly:

    {title:"Name", field:"name", formatter:myCustomFormatter, variableHeight:true}