How to Add Filtering & Pagination to Your Data Tables With Hotwire

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 30. 05. 2024
  • Having a way to filter records in a table was always clunky in Rails because you'd either have to write a lot of javascript and figure out how to make it work with pagination, or you'd not use Javascript at all and only do it server-side but that didn't feel very responsive and modern.
    But thankfully now that we have Hotwire, adding filtering to a table with pagination can be done in just a few minutes.
    đŸŽ„ Join my new Ruby on Rails Class here: mixandgo.com/rails-class
    👉 Buy my Bulletproof Ruby on Rails Applications eBook: j.mp/2OtFCdR
    🍿 Hotwire playlist: ‱ Ruby on Rails - Hotwire
    Github Repository: github.com/mixandgo/hotwire_f...
    My website: mixandgo.com
    #rubyonrails #rails7 #hotwire #stimulusjs #turbo #ruby #webdev

Komentáƙe • 40

  • @climatemojo
    @climatemojo Pƙed 12 dny

    Super helpful, Cezar. Thanks for the details on updating a frame other than the one initiating the action.

    • @mixandgo
      @mixandgo  Pƙed 12 dny

      Glad to hear you like it.

  • @withrejkapermana6087
    @withrejkapermana6087 Pƙed rokem +2

    You explain how it works and I think how easy it is to implement. Thank you! Nice video anyway!

  • @ramses-lopez
    @ramses-lopez Pƙed 2 lety +1

    straight to the point. Love it.

  • @decud1320
    @decud1320 Pƙed rokem

    Nice one and well explained. Thanks for sharing !

  • @martijnlafeber
    @martijnlafeber Pƙed 2 lety +4

    I love the information density of your videos, excellent job!

    • @mixandgo
      @mixandgo  Pƙed 2 lety

      I'm glad you like them :)

    • @aleksandarjeftic2847
      @aleksandarjeftic2847 Pƙed rokem

      @@mixandgo really amazing, I appreciate it much

    • @wakematta
      @wakematta Pƙed rokem

      And having the chapters in the video helps a lot. To find quickly the stuff that you saw at some point but u'you forgotten.

  • @ledockol
    @ledockol Pƙed 2 lety

    Just wonderful. Thanks

  • @juliolinarezescobar
    @juliolinarezescobar Pƙed 2 lety

    Great Job.

  • @user-dv1vu1om6o
    @user-dv1vu1om6o Pƙed 27 dny

    Very good

  • @viktorsmari
    @viktorsmari Pƙed 2 lety

    Great video! Do you know how we would add the link_extra: to the Kaminari gem?

    • @mixandgo
      @mixandgo  Pƙed 2 lety +1

      One option is to generate the views and customize the links github.com/kaminari/kaminari#customizing-the-pagination-helper.
      You could replace `remote: remote` with `data: { turbo_action: "advance" }` like this:
      ```
      ```

  • @kianworkshop7066
    @kianworkshop7066 Pƙed rokem

    Do you have guides for sorting? Can't find good guides for sorting or integrating dataTables to rails 7.
    Thanks!

    • @mixandgo
      @mixandgo  Pƙed rokem +1

      I don't think I do. The closest might be this one: czcams.com/video/4MUEQVxUbm4/video.html which is how I would probably do sorting as well.

    • @kianworkshop7066
      @kianworkshop7066 Pƙed rokem

      @@mixandgo Thanks! Will check it out.

  • @julianogarcia9821
    @julianogarcia9821 Pƙed 2 lety

    amazing

  • @eutcb
    @eutcb Pƙed rokem

    Hello, thanks for the video.
    Just a question, I configured the form controller but it is not searching automatically, only when I press Enter

    • @mixandgo
      @mixandgo  Pƙed rokem +1

      Do you have a keyup handler?

    • @eutcb
      @eutcb Pƙed rokem

      @@mixandgo I did it, apparently there was an error with my Hotwire, I reconfigured it, did a yarn build and it worked.
      Thanks for the answer, in January I'm going to buy your Rails 7 course, there's a lot of cool new stuff.

    • @mixandgo
      @mixandgo  Pƙed rokem +1

      @@eutcb it's great to hear it worked 👍

    • @eutcb
      @eutcb Pƙed rokem

      @@mixandgo one more thing, every time I modify a stimulus controller, I need to run yarn build and start rails again. it's normal?

    • @mixandgo
      @mixandgo  Pƙed rokem

      @@eutcb no, that's not normal. Don't you have a ./bin/dev script?

  • @JackRiminton
    @JackRiminton Pƙed rokem

    Did I miss the bit where you explain why you can't use elements or did you just decide to skip that entirely?

    • @mixandgo
      @mixandgo  Pƙed rokem

      Tables don't allow you to mix in other tags.

  • @clementblgr6498
    @clementblgr6498 Pƙed rokem

    this video is outdated. Today it's version 5.10
    For me, 'items: x' not working

    • @mixandgo
      @mixandgo  Pƙed rokem

      What is version 5.10?

    • @clementblgr6498
      @clementblgr6498 Pƙed rokem

      @@mixandgo I'm talking about pahy but sorry I am a noob xD
      I think my 'items: 10' don't work because I render a partial for my contacts and not the '@contacts'

    • @mixandgo
      @mixandgo  Pƙed rokem

      @@clementblgr6498 you mean "pagy". Well, that's still at version 5.10 (which is what I use in the video)

    • @clementblgr6498
      @clementblgr6498 Pƙed rokem

      @@mixandgo yeah pagy sorry, everything is okay now !
      It was just because I dont loop on '@contacts' but on 'current_user.contacts'.
      Sorry for wasting your time.
      Btw you are doing really useful videos but maybe a little bit fast ':D

    • @mixandgo
      @mixandgo  Pƙed rokem

      @@clementblgr6498 thanks, I appreciate the feedback.

  • @atekeltafework4744
    @atekeltafework4744 Pƙed rokem +1

    i really love your videos, But as a developer just starting using RoR you go really fast and not that detailed explanations. can you improve that for us noobs?

    • @mixandgo
      @mixandgo  Pƙed rokem +1

      There's a lot going on in these videos, and I'm not sure speed is your main problem if you're a noob.
      These videos are less about learning Rails, and more like cool stuff you can build with Rails.
      But I get your point. I'll see what I can do.

    • @AJ23mady
      @AJ23mady Pƙed rokem

      These videos aren't for noobs