kishanov / re-frame-datatable

DataTable component for re-frame library
https://kishanov.github.io/re-frame-datatable/
Eclipse Public License 1.0
103 stars 16 forks source link

How to re-render the datatable #15

Open jcthalys opened 6 years ago

jcthalys commented 6 years ago

Hi, I'm using this data-table with a subscribe to a reg-sub-raw that receive and dispatch a get to the server and return the new values

(defn score-board [day]

  (let [_ (println "score-board " day)]
    [re-com/scroller
     :child
     [re-com/h-box
      :gap "12px"
      :size "1"
      :children
      [[dt/datatable
        :equipments
        [:monitor.score/daily-board day]
        [{::dt/column-key   [:id]
          ::dt/column-label "Equipmento"}
         .......]
        {::dt/table-classes ["ui" "table" "celled"]}]]
      ]]))

I would like that this line execute avery time this day change

[:monitor.score/daily-board day]

By that log I could check that is changing the date

Thus, every time re-run the values should be re-render the data table with new values:

(re-frame/reg-sub-raw
  :monitor.score/daily-board

  (fn [db [_ day]]
    (dispetch [:monitor.score/load-daily-score day])

    (make-reaction
      (fn []
        (get-in @db [:app/panels :panel/monitor-score :daily-scores] [])))))

But, this is happening only the first time is rendered or when a run from repl this subscription load the new values and the data table is rendered OK.

I really appreciate any help you can provide

jcthalys commented 6 years ago

I tried without re-frame-datatable and everything works well: Every time that day-str changes, the table is re-rendered by the new result.

[:table.table
        [:thead.data-table-header [:tr
                                   [:th "Equipmento"]
                                   [:th "Gropo"]
                                   [:th "Modelo"]
                                   [:th "00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00
                                         12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:00"]]]
        (into [:tbody] (for [equipment @(re-frame/subscribe [:monitor.score/daily-board day-str])]
                         [:tr
                          [:td (:id equipment)]
                          [:td (get-in equipment [:group :name])]
                          [:td (get-in equipment [:model :name])]
                          [:td [StatusBar (:snapshots equipment)]]]))]
polvoblanco commented 5 years ago

Did you ever get this working with re-frame-datatable?

jcthalys commented 5 years ago

no, I did other solution