Genie Discord forum

Author Avataraww
12/4/2023, 1:25:37 PM

I'm trying to implement a search component for a table (code is available in a component gallery) but I'm getting always the same error, instead of showing a table I see only ="" v-slot:top-right=""> in a place where entire table should be visible. Do you have some hints how to solve that? BTW, is it possible to apply search across entire table and not for one column?

Author Avataraww
12/4/2023, 1:26:00 PM

Changed the channel name: Search component for a table

Author AvatarPere
12/5/2023, 2:28:56 PM

can you share a MWE so that I can try it out and see if I can figure out why it's not working?

Author Avataressenciary
12/5/2023, 4:16:49 PM

I think we broke it recently

Author Avataressenciary
12/5/2023, 4:17:36 PM

it used to work with client side data only - but I added client side data support - and there is an issue about breaking client side search

Author Avataressenciary
12/5/2023, 4:17:47 PM

but yes, a minimum example would help

Author Avataressenciary
12/5/2023, 4:17:54 PM

as an issue in StippleUI.jl

Author Avataraww
12/6/2023, 6:05:09 AM

Hey both, I'm sharing an example which is taken directly from Genie's component gallery. As an output you see only as shown

    module App
    using GenieFramework, DataFrames
    @genietools
    
    @app begin
        @out TableSearch_data = DataTable(
            DataFrame(
                name = [
                    "Frozen Yogurt",
                    "Ice cream sandwich",
                    "Eclair",
                    "Cupcake",
                    "Gingerbread",
                    "Jelly bean",
                    "Lollipop",
                    "Honeycomb",
                    "Donut",
                    "KitKat",
                ],
                calories = [159, 237, 262, 305, 356, 375, 392, 408, 452, 518],
                fat = [6.0, 9.0, 16.0, 3.7, 16.0, 0.0, 0.2, 3.2, 25.0, 26.0],
                carbs = [24, 37, 23, 67, 49, 94, 98, 87, 51, 65],
            ),
        )
        @in TableSearch_dfilter = ""
    end
    
    ui() = [
        table(
            :TableSearch_data,
            flat = true,
            bordered = true,
            title = "Treats",
            var"row-key" = "name",
            filter = :TableSearch_dfilter,
            hideheader = "",
            template(
                var"v-slot:top-right" = "",
                textfield(
                    "",
                    :TableSearch_dfilter,
                    dense = true,
                    debounce = "300",
                    placeholder = "Search",
                    [template(var"v-slot:append" = true, icon("search"))],
                ),
            ),
        )
    ]
    
    @page("/", ui)
    
    up()
    end
Author Avatarhhaensel
12/29/2023, 11:38:33 PM

That's an error from our side. Until a fix is in place, you can workaround it by supplying an extra empty string and put the template in Vector brackets

hideheader = "", "", 
[template(...

)]
Author Avatarhhaensel
12/29/2023, 11:40:09 PM

It's fixed in master ...

Author Avatarhhaensel
12/29/2023, 11:41:07 PM

@Pere @essenciary please check whether everything works and tag a new version if it's fine. I'll be offline until next year most probably

Author Avatarhhaensel
1/3/2024, 12:52:18 AM

It's done. v0.22.12 is in place. Happy New Year! ๐Ÿ€

Author Avataraww
1/3/2024, 5:03:05 AM

Big Thank you and happy New Year! how am I suppose to use it? Packages are updated, if I simply copy/paste the code from component gallery (tables + search) then it throwns an error as above, if I add an empty string and include template in a square brackets then table is shown but search option doesn't work.

Author Avatarhhaensel
1/4/2024, 8:52:39 AM

No template is needed, just pass filter = :TableSearch_dfilter and you're done

Author AvatarPere
1/4/2024, 9:33:49 AM

I'll update the gallery then

Author Avatarhhaensel
1/4/2024, 9:45:27 AM

This app works:

@app begin
    @out TableSearch_data = DataTable(
        DataFrame(
            name = [
                "Frozen Yogurt",
                "Ice cream sandwich",
                "Eclair",
                "Cupcake",
                "Gingerbread",
                "Jelly bean",
                "Lollipop",
                "Honeycomb",
                "Donut",
                "KitKat",
            ],
            calories = [159, 237, 262, 305, 356, 375, 392, 408, 452, 518],
            fat = [6.0, 9.0, 16.0, 3.7, 16.0, 0.0, 0.2, 3.2, 25.0, 26.0],
            carbs = [24, 37, 23, 67, 49, 94, 98, 87, 51, 65],
        ),
    )
    @in TableSearch_dfilter = ""
end

ui() = [
    table(
        :TableSearch_data,
        flat = true,
        bordered = true,
        title = "Treats",
        var"row-key" = "name",
        filter = :TableSearch_dfilter,
        hideheader = "",
        template(
            var"v-slot:top-right" = "",
            textfield(
                "",
                :TableSearch_dfilter,
                dense = true,
                debounce = "300",
                placeholder = "Search",
                [template(var"v-slot:append" = true, icon("search"))],
            ),
        ),
    )
]

@page("/", ui)
Author Avatarhhaensel
1/4/2024, 9:46:41 AM

Sorry, hang on a moment

Author Avatarhhaensel
1/4/2024, 9:58:12 AM

The automatic template is only added if (Table.jl line 250)

 if filter !== nothing && paginationsync !== nothing 

Not really clear to me why. Maybe @essenciary can help. But the app above does work with the template added manually.

Author Avatarhhaensel
1/4/2024, 10:00:22 AM

Just saw that @essenciary has added && paginationsync !== nothing yesterday. That's why it doesn't work anymore.

Author Avataressenciary
1/4/2024, 10:02:57 AM

it was not supposed to work like that - at least not in a non-breaking release

Author Avataressenciary
1/4/2024, 10:03:53 AM

because it breaks existing code where users manually added the filter

Author Avataressenciary
1/4/2024, 10:04:41 AM

and in the version you patched the filter was actually rendered twice

Author Avatarhhaensel
1/4/2024, 10:04:50 AM

yip, I realised that

Author Avataressenciary
1/4/2024, 10:05:55 AM

so my assumption was: use this for server side so it's non breaking. potentially improve logic in a breaking release (asking users to remove manual code)

Author Avatarhhaensel
1/4/2024, 10:06:02 AM

BTW, couldn't we add the functionality, that ParsedHTMLString is always added as child and never as am attribute

Author AvatarPere
1/4/2024, 10:23:32 AM

So, I updated StippleUI to v0.22.13 in the gallery app and the table search is working again. I did not have to change any code. @aww please let me know if it works after updating StippleUI to the latest version.

Author Avataraww
1/4/2024, 11:49:36 AM

it looks like everything works, thank you All for fixing that!

Author Avataressenciary
1/4/2024, 1:10:53 PM

@Pere lets discuss surfacing a server side filtering and pagination example for data tables

Author Avataressenciary
1/4/2024, 1:11:25 PM

client side pagination and filtering is only feasabile for small amounts of data

Author Avataressenciary
1/4/2024, 1:12:57 PM

FYI this demo will cause issues on Julia 1.10 due to this https://github.com/GenieFramework/Stipple.jl/issues/248