From 19c729dcf5854c528053d71a9c9c38d01d2ac923 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 19 Sep 2009 14:21:25 -0400 Subject: Paging mostly working; just need to get it working properly with filtering --- demo/more/grid.ur | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'demo/more/grid.ur') diff --git a/demo/more/grid.ur b/demo/more/grid.ur index 560ff146..d63a1424 100644 --- a/demo/more/grid.ur +++ b/demo/more/grid.ur @@ -37,6 +37,8 @@ functor Make(M : sig con aggregates :: {Type} val aggregates : $(map (aggregateMeta row) aggregates) val aggFolder : folder aggregates + + val pageLength : option int end) = struct style tabl style tr @@ -59,7 +61,8 @@ functor Make(M : sig Selected : source bool}, Selection : source bool, Filters : $(map thd3 M.cols), - Sort : source (option (M.row -> M.row -> bool))} + Sort : source (option (M.row -> M.row -> bool)), + Position : source int} fun newRow cols row = rowS <- source row; @@ -89,12 +92,14 @@ functor Make(M : sig rows <- Dlist.create; sel <- source False; sort <- source None; + pos <- source 0; return {Cols = cols, Rows = rows, Selection = sel, Filters = filters, - Sort = sort} + Sort = sort, + Position = pos} fun sync {Cols = cols, Rows = rows, ...} = Dlist.clear rows; @@ -216,8 +221,8 @@ functor Make(M : sig [_] M.folder grid.Cols M.cols cols)}/> end) - {StartPosition = return (Some 1), - MaxLength = return (Some 2), + {StartPosition = Monad.mp Some (signal grid.Position), + MaxLength = return M.pageLength, Filter = fn all => row <- signal all.Row; foldR3 [colMeta M.row] [fst3] [thd3] [fn _ => M.row -> signal bool] @@ -258,6 +263,42 @@ functor Make(M : sig [_] M.folder M.cols grid.Cols grid.Filters} + + {case M.pageLength of + None => + | Some plen => + + else + let + val numPages = avail / plen + val numPages = if numPages * plen < avail then + numPages + 1 + else + numPages + + fun pages n = + if n * plen >= avail then + + else + + {[n + 1]} + else + +