petal_components icon indicating copy to clipboard operation
petal_components copied to clipboard

Table with stream clears upon update

Open storkweb opened this issue 1 year ago • 1 comments

Hi, Trying the Table component (v 1.9.0) but it clears all shown values upon update (yes I put the phx-update="stream" that's missing from the example). it seems that the <:col> has no id but how can I specify the field from the stream in the table's row_id ?

Thanks

storkweb avatar Jan 29 '24 14:01 storkweb

hmm. did you try the row_id attribute? Looks like I need to update the doc.

<.table
  id="users"
  rows={@streams.users}
  row_click={fn {_id, user} -> JS.navigate(~p"/users/#{user}") end}
  row_id={fn {_id, user} -> "user--#{user.id}" end}
>

Here is the code: https://github.com/petalframework/petal_components/blob/main/lib/petal_components/table.ex

I used the phx generator as a base and adapted it to Petal.

mplatts avatar Feb 05 '24 03:02 mplatts