Closed drammelt closed 8 months ago
How is the data class defined?
Not 100% sure what you mean, if you mean the data from the Ajax endpoint its just json data.
Using the same endpoint as the example above the following code will not throw an exception...
tabulator(
options = TabulatorOptions(
height = "calc(100vh - ${tabHeight + Dimentions.TOP_BAR_HEIGHT.first.toInt() + Dimentions.SEARCH_BAR_HEIGHT.first.toInt()}px)",
pagination = true,
ajaxURL = ajaxURL,
ajaxConfig = "POST",
ajaxContentType = "json",
paginationMode = PaginationMode.REMOTE,
filterMode = FilterMode.REMOTE,
sortMode = SortMode.REMOTE,
layout = Layout.FITCOLUMNS,
columns = listOf(
ColumnDefinition(title = "ID", field = "id", width = "100"),
)
)
)
Only if I add a column using formatterComponentFunction will it fail.
If I assume correctly you are using a tabulator component without a strict type (Tabulator<dynamic>
). In this case formatterComponentFunction
will not currently work in KVision 6.
The formatterComponentFunction
was generally designed to work with Kotlin data model. With dropping the legacy backend support, the Tabulator
component is now more strict when it comes to Kotlin data model. With current implementation, you need to define a @Serializable
Kotlin data class, use typed Tabulator<T>
and also pass a serializer
parameter to allow Tabulator
component convert internal JavaScript model to Kotlin model.
I will look at the code a bit more and check if it would be possible to just pass the dynamic data without any conversion.
That is correct, thank you for clearing that up.
Moved the AjaxDTO to common code.
Made data models in the common code generic (had to remove ZonedDateTime fields and replace with String as there appears to be no way to create a KSerializer for kvisions ZonedDateTime as it has no constructors in common code and contextual does not work when calling from the backend as it has no idea about kvisions datetime).
Changed all tabulators to use specific data model and added serializer and it all works fine now.
Thank you.
Fixed in 7.1.0
I have been in the process of upgrading our projects KVision from 5.18.1 to 6.2.2 and have run into this issue. Previously all the tabulator tables were working correctly but since changing to 6.2.2 it throws an exception when any column contains a formatterComponentFunction. If I remove these columns the tabulator will load correctly with no exceptions. If I remove everything except for the formatterComponentFunction column it will still throw an exception.
This is the most stripped down example of what is failing (It works fine if I remove the ajax calls and just use local data, so the issue appears to be caused by using Ajax data?)
Exception...