 
 ;; SLICKGRID HELPER FUNCTIONS
 
-(defn compfn [args]
+(defn compfn
   "Comparator function for the slickgrid dataview.
    args.sortCol is the column being sorted, a and b are rows to compare.
    Claims a is bigger (return 1) if value for a > b, or a is null / empty."
+  [args]
   (fn [a b]
     (let [col (aget args "sortCol")
           lower #(if (string? %) (clojure.string/lower-case %) %)

          bval (lower (aget b (aget col "field")))]
      (if (or (nil? aval) (> aval bval)) 1 -1))))

(defn filterfn [form item args]
  "Filter function for the slickgrid dataview, use as (partial filterfn form)
   item is the row, args contains query.
   Return value of false corresponds with exclusion, true with inclusion."
  (if-not args
    true ; don't filter anything if args is undefined
    (let [indexed-form (zipmap (map :full-name form) form)

               event (aget grid handler-name)]]
     (.subscribe event handler-function))))

(defn sg-init
  "Creates a Slick.Grid backed by Slick.Data.DataView from data and fields.
   Most events are handled by slickgrid. On double-click, event is put on chan.
   Returns [grid dataview]."
  [data form is-filtered-dataview? external-event-handlers]
  (let [columns (flat-form->sg-columns
                 form true nil :is-filtered-dataview? is-filtered-dataview?)
        SlickGrid (.. js/Slick -Grid)
        DataView (.. js/Slick -Data -DataView)
        dataview (DataView.)
