Store a headerFilter with a persistent layout in Tabulator 3.5

93 Views Asked by At

I try to store my filter field into JSON object during the navigation process and get this Javascript issue in tabulator.js:

Options Error - Tabulator does not allow options to be set after initialization unless there is a function defined for that purpose

(java class)

    JsonObject configuracion = new JsonObject();
    configuracion.addProperty("height", "92%");
    configuracion.addProperty("tooltips", true);
    configuracion.addProperty("tooltipsHeader", true);


    configuracion.addProperty("persistentLayout", true); 
    configuracion.addProperty("layout","fitDataFill"); 
    configuracion.addProperty("persistenceMode", true); 
    configuracion.addProperty("persistenceID", myBandeja.getStrBandejaLogicaCaption().substring(0,4)); 
    configuracion.addProperty("persistentFilter", true);
    configuracion.addProperty("movableColumns", true);
    configuracion.addProperty("selectable", true);
    configuracion.addProperty("virtualDomBuffer",500);


    JsonObject fila = new JsonObject();
    JsonArray datasets = new JsonArray();
    for (Entry<Integer, String> entry : myTitleRow.entrySet()) {
                fila = new JsonObject();
                fila.addProperty("title", entry.getValue());
                fila.addProperty("field", entry.getValue());
                fila.addProperty("sorter", "string");
                fila.addProperty("headerFilter", "input");
                fila.addProperty("headerFilterPlaceholder", "Filtrar...");
                fila.addProperty("cellClick", "cellClickBandeja(e, cell);");

                datasets.add(fila);
        }
    configuracion.add("columns", datasets);

Some property is sorting wrong?

Thanks in advance.

1

There are 1 best solutions below

0
Oli Folkerd On

When you get that message it is either either one of two things.

You are trying to change an option after the Tabulator has been created using jQuery's option function which Tabulator does not allow.

Or because you are trying to re declare your table on an element that is already a Tabulator. If that is the case then you need to call the destroy function on the table before you create it again:

$("#example-table").tabulator("destroy");