From: Andrea Zagli Date: Mon, 2 Jan 2023 15:25:18 +0000 (+0100) Subject: Setting header and header row template. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=48992631b58a0129a83fd2e595c379e03add220a;p=rust%2Fzakgrid Setting header and header row template. --- diff --git a/examples/grid.rs b/examples/grid.rs index c255fe4..ba287d8 100644 --- a/examples/grid.rs +++ b/examples/grid.rs @@ -45,6 +45,9 @@ async fn index( let mut grid = zakgrid::Grid::new(); + grid.set_header_tmpl(String::from("\n{{ row }}\n")); + grid.set_header_row_tmpl(String::from("\t{{ title }}\n")); + let mut s = String::new(); s.push_str(""); @@ -67,7 +70,7 @@ async fn index( } s.push_str("

\n"); - s.push_str("\n"); + s.push_str("
\n"); let header = grid.header(); s.push_str(header.as_str()); s.push_str("
\n"); diff --git a/src/lib.rs b/src/lib.rs index 3f46bb7..44465dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,14 @@ impl Grid { } } + pub fn set_header_tmpl(&mut self, tmpl: String) { + self.header_tmpl = tmpl; + } + + pub fn set_header_row_tmpl(&mut self, tmpl: String) { + self.header_row_tmpl = tmpl; + } + pub fn add_column(&mut self, col: Column) { self.columns.push(col); }