-
Notifications
You must be signed in to change notification settings - Fork 0
/
template-25.html
78 lines (74 loc) · 3.49 KB
/
template-25.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<h1 id="column-alignment">Column Alignment</h1>
<p>Column content can be aligned to the <em>left</em>, <em>center</em>, or <em>right</em> using the property <code>alignment</code> in the column definition. The <code>alignment</code> property will be applied for both column content and header by default. </p>
<p>Column header alignment can be separately set on <code>headerAlignment</code> property. The <code>headerAlignment</code> property will override the <code>alignment</code> property for the column header. </p>
<p>The default value for both <code>alignment</code> and <code>headerAlignment</code> is <em>left</em>.</p>
<pre><code class="language-js">var configObj = {
...
columns: [
{
alignment: "left",
headerAlignment: "center"
},
...
],
...
}
</code></pre>
<h2 id="example">Example</h2>
<code-sandbox hash="18767de5"><pre><code class="language-css">html hr {
margin: 5px;
}
efx-grid {
height: 200px;
}
</code></pre>
<pre><code class="language-html"><button id="lft_btn">Left Alignment</button>
<button id="ctr_btn">Center Alignment</button>
<button id="rgt_btn">Right Alignment</button>
<button id="reset_btn">Reset Alignment</button>
<hr>
<efx-grid id="grid"></efx-grid>
</code></pre>
<pre><code class="language-javascript">import { halo } from './theme-loader.js'; // This line is only required for demo purpose. It is not relevant for your application.
await halo(); // This line is only required for demo purpose. It is not relevant for your application.
/* ---------------------------------- Note ----------------------------------
DataGenerator, Formatters and extensions are exposed to global scope
in the bundle file to make it easier to create live examples.
Importing formatters and extensions is still required in your application.
Please see the document for further information.
---------------------------------------------------------------------------*/
function setAlignment(alignment) {
var core = grid.api.getCoreGrid();
var colCount = core.getColumnCount();
for(var c = 0; c < colCount; ++c) {
core.setColumnAlignment(c, alignment);
}
}
lft_btn.addEventListener("click", function(e) {
setAlignment("l");
});
ctr_btn.addEventListener("click", function(e) {
setAlignment("c");
});
rgt_btn.addEventListener("click", function(e) {
setAlignment("r");
});
reset_btn.addEventListener("click", function(e) {
setAlignment("");
});
var fields = ["companyName", "market", "CF_LAST", "CF_NETCHNG", "industry"];
var records = DataGenerator.generateRecords(fields, { numRows: 5 });
var configObj = {
columns: [
{name: "Default", field: fields[0]},
{name: "Center Header", field: fields[1], alignment: "center", headerAlignment: "center"},
{name: "Last", field: fields[2],alignment: "right", headerAlignment: "left"},
{name: "Net. Chng", field: fields[3], alignment: "right"},
{name: "Center Header", field: fields[4], headerAlignment: "center"}
],
staticDataRows: records
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
</code-sandbox>