Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns grid-test.core
- (:require [reagent.core :as reagent :refer [atom]]
- [react-data-grid :as ReactDataGrid]
- [ag-grid-react :refer [AgGridReact]]))
- ;; define your app data so that it doesn't get over-written on reload
- (defonce app-state (atom {:text "Olรก Mundo!!"}))
- (defn hello-world []
- [:div
- [:h1 (:text @app-state)]
- [:h3 "Edit this and watch it not change!"]])
- (defn some-grid []
- (let [columns [{:key "id" :name "ID"}
- {:key "title" :name "Title" :editable true}]
- rows [{:id 0 :title "Zerimo"}
- {:id 1 :title "Primeiro"}
- {:id 2 :title "Segundo"}]]
- [:div.container
- [:div.row
- [:div.col-md-12
- [:> ReactDataGrid {:columns columns
- :rowGetter #(get (clj->js rows) %)
- :rowsCount 3
- :enableCellSelect true}]]]]
- )
- )
- (defn on-cell-clicked [& args]
- (js/console.log args))
- (defn row-style [selected-id params]
- (when (= selected-id (-> (js->clj params) (get "data") (get "id")))
- (clj->js {:background-color "#b7e4ff"})))
- (defn other-grid [selected-id]
- (let [columns [{:field "id" :headerName "ID"}
- {:field "title" :headerName "Title" :editable true}]
- rows [{:id 0 :title "Zerimo"}
- {:id 1 :title "Primeiro"}
- {:id 2 :title "Segundo"}]]
- [:div.container
- [:div.row
- [:div.col-md-12
- [:div.ag-theme-balham {:style {:height "500px" :width "100%"}}
- [:> AgGridReact {:gridOptions {:columnDefs columns
- :rowData rows
- :rowSelection "single"
- :onCellClicked on-cell-clicked
- ;; :onRowClicked on-cell-clicked
- :getRowStyle (partial row-style selected-id)}}]]]]]
- )
- )
- (defn start []
- (reagent/render-component [other-grid 1]
- (. js/document (getElementById "app"))))
- (defn ^:export init []
- ;; init is called ONCE when the page loads
- ;; this is called in the index.html and must be exported
- ;; so it is available even in :advanced release builds
- (start))
- (defn stop []
- ;; stop is called before any code is reloaded
- ;; this is controlled by :before-load in the config
- (js/console.log "stop"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement