Genie Discord forum

Author Avatarwerner castro
9/22/2023, 2:30:36 AM

Is it possible to access the index of a row in a table, through the click event, as happens in the plot event ?

Author AvatarPere
9/22/2023, 2:32:19 PM

You'd have to use quasar's v-on:row-clickevent. Here's how to

using GenieFramework
using DataFrames
@genietools

@app begin
    @in id = 0
    @in rowcontent = ""
    @out data = DataTable(DataFrame(a = rand(5) , b = rand(5)))
    @onchange id begin
        @show id
    end
    @onchange rowcontent begin
        @show rowcontent
    end
end

function ui()
    [
     p("Row: {{id}}, {{rowcontent}}")
     table(:data, var"v-on:row-click"="function(event,row) {id=row.__id;rowcontent=row}")
   ]
end
@page("/", ui)
up()
Author AvatarPere
9/22/2023, 2:33:22 PM

This defines an anonymous Javascript function that is executed when the click event is triggered. This event generates an event code and a row variable with the row contents, which we pass to the anonymous function.

Author Avatarwerner castro
9/22/2023, 2:36:52 PM

@Pere It was incredible