Skip to content

How can I use <span> in table_ops and pagination_ops? #384

Answered by woylie
kuatroka asked this question in Q&A
Discussion options

You must be logged in to vote

You can add a wrapper around the pagination component and derive values from the Flop.Meta struct. Roughly:

 attr :meta, Flop.Meta, required: true
 attr :path, :any, default: nil
 attr :on_paginate, JS, default: nil
 attr :target, :any, default: nil

 def pagination(%{meta: meta} = assigns) do
   assigns =
     assign(assigns,
       from: meta.current_offset + 1,
       to: min(meta.current_offset + meta.page_size, meta.total_count)
     )

   ~H"""
   <div :if={@meta.total_pages > 1}>
     <div>Showing {@from}-{@to} of {@meta.total_count}</div>
     <Flop.Phoenix.pagination
       meta={@meta}
       path={@path}
       on_paginate={@on_paginate}
       target={@target}
     />
   </div>

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@kuatroka
Comment options

@woylie
Comment options

@kuatroka
Comment options

@woylie
Comment options

@kuatroka
Comment options

Answer selected by kuatroka
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants