You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to add interactivity to a table such that when a click is made on a row, the row id and its content are stored in two variables idand rowcontent. I have two handlers attached to each of the variables to display their contents when they change. When I select a row, the variable rowcontentis updated in the front end but its value is not propagated to the back. This is the event handler definition
However, if I do rowcontent = String(row) then it works.
Moreover, I have two buttons to clear the selection. One clears the variables directly, whereas the other uses an anonymous function. Both buttons work so the issue seems not to be in the use of an anonymous function.
Perhaps it's that assigning one variable to the other like rowcontent=rowdoes not trigger the handler in table event functions?
Here's the MWE code:
using GenieFramework
using DataFrames
@genietools@appbegin@in id =0@in rowcontent =""@in placeholder ="placeholder"@out data =DataTable(DataFrame(a =rand(5) , b =rand(5)))
@onchange id begin@show id
end@onchange rowcontent begin@show rowcontent
endendfunctionui()
[
p("Row: {{id}}, {{rowcontent}}")
table(:data, var"v-on:row-click"="function(event,row) {id=row.__id;rowcontent=row}")
btn("Remove selection",@click("id=0; rowcontent=placeholder"))
btn("Anonymous remove selection",@click("function() {id=0; rowcontent=placeholder}"))
]
end@page("/", ui)
up()
The text was updated successfully, but these errors were encountered:
It does trigger the backend, but it fails assigning the value to rowcontent, because rowcontent is initialised to be of type String, but rowcontent on the client side is an object.
Whenever you are not sure what will be transmitted by the program, you can initialise the app variable of type Any.
@appbegin@in id =0@in rowcontent::Any=""<...>end
Then click the row and you will find that rowcontent is of type Dict{String, Any} and you can chose this type for initialisation.
You could, of course, also initalise rowcontent as row = Dict{Symbol, Any}(), and everything will work out as well.
I'm trying to add interactivity to a table such that when a click is made on a row, the row id and its content are stored in two variables
id
androwcontent
. I have two handlers attached to each of the variables to display their contents when they change. When I select a row, the variablerowcontent
is updated in the front end but its value is not propagated to the back. This is the event handler definitionHowever, if I do
rowcontent = String(row)
then it works.Moreover, I have two buttons to clear the selection. One clears the variables directly, whereas the other uses an anonymous function. Both buttons work so the issue seems not to be in the use of an anonymous function.
Perhaps it's that assigning one variable to the other like
rowcontent=row
does not trigger the handler in table event functions?Here's the MWE code:
The text was updated successfully, but these errors were encountered: