Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tabulator onTableBuilt callback for JsTabulator construction completion #557

Closed
wants to merge 2 commits into from

Conversation

tfonrouge
Copy link
Contributor

Introduce a new onTableBuilt lambda function triggered when the table building process is finished. This allows developers to execute custom logic post table initialization, enhancing flexibility and customization.

Introduce a new onTableBuilt lambda function triggered when the table building process is finished. This allows developers to execute custom logic post table initialization, enhancing flexibility and customization.
@tfonrouge
Copy link
Contributor Author

tfonrouge commented Dec 30, 2024

An example usage is when you want to dynamically add columns to the tabulator with the Tabulator.addColumn, but the Tabulator.addColumn function need the jsTabulator var initialized:

    open fun addColumn(
        columnDefinition: JsTabulator.ColumnDefinition,
        insertRightOfTarget: Boolean? = null,
        positionTarget: String? = null
    ) {
        jsTabulator?.addColumn(columnDefinition, insertRightOfTarget, positionTarget)
    }

So you can easily add the logic with a callback function triggered when the jsTabulator?.on("tableBuilt") event is called.

But maybe I'm missing something and this can be achieved in another established way.

ty

@rjaros
Copy link
Owner

rjaros commented Jan 2, 2025

In general it should be enough to use addAfterInsertHook { }, like this:

tabulator(...) {
    addAfterInsertHook {
        jsTabulator?.on("tableBuilt") {
            // your code here 
        }
    }
}

But, if you want simpler code, I think more concise way would be to add custom tableBuiltTabulator event, similar to how some other tabulator events are dispatched: https://github.com/rjaros/kvision/blob/master/kvision-modules/kvision-tabulator/src/jsMain/kotlin/io/kvision/tabulator/Tabulator.kt#L231

@tfonrouge tfonrouge closed this by deleting the head repository Jan 2, 2025
@tfonrouge
Copy link
Contributor Author

I think that is better the simpler code you stated. I'll make a PR , thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants