Skip to Content
Building Table Views with Phoenix LiveView
book

Building Table Views with Phoenix LiveView

by Peter Ullrich
January 2023
Intermediate to advanced
67 pages
1h 42m
English
Pragmatic Bookshelf
Content preview from Building Table Views with Phoenix LiveView

Adding Pagination to the LiveView

Before we can use the PaginationComponent, we need to add it to our HEEx template. Please open up lib/meow_web/live/meerkat_live.html.heex and add the following code:

 <div>
 <!-- Filter form stays here -->
 
 <!-- Table stays here -->
 
 <!-- Add this .live_component -->
  <​.​live_component
  module=​{MeowWeb.MeerkatLive.PaginationComponent}
  id=​"pagination"
  pagination=​{@pagination}​ />
 </div>

This will render our PaginationComponent beneath the table. Now, we need to assign our default @pagination values. Open up the LiveView at lib/meow_web/live/meerkat_live.ex and update the code as follows:

 defmodule​ MeowWeb.MeerkatLive ​do
 use​ MeowWeb, ​:live_view
 
 # Other aliases omitted ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Craft GraphQL APIs in Elixir with Absinthe

Craft GraphQL APIs in Elixir with Absinthe

Bruce Williams, Ben Wilson
Realm of Racket

Realm of Racket

Conrad Barski M.D., David Van Horn, Eight Students of Northeastern University, Matthias Felleisen
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9798888650097Errata Page