-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-129.html
64 lines (60 loc) · 3.28 KB
/
template-129.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
<h1 id="row---showhide">Row - Show/Hide</h1>
<p>Content rows can be hidden and shown based on their row ID, and an additional API unhides all currently hidden rows.</p>
<blockquote>
<p><strong>Note:</strong> In most cases, the row ID is not equivalent to the row index. It can, however, be retrieved if you know the index (refer to the JavaScript section in the demo).</p>
</blockquote>
<p>Both the <code>showRows()</code> and <code>hideRows()</code> APIs accept either an individual value (string or integer) or an array of values. This kind of state is independent of the programmatic filtering of content, and will correctly reclassify hidden rows on sorting/grouping.</p>
<h2 id="example">Example</h2>
<code-sandbox hash="9ccc4e3c"><pre><code class="language-css">html hr {
margin: 5px;
}
efx-grid {
height: 200px;
}
</code></pre>
<pre><code class="language-html"><button id="hide_btn">Hide top 3 rows</button>
<button id="show_btn">Show last 2 hidden rows</button>
<button id="clear_btn">Unhide all</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.
---------------------------------------------------------------------------*/
var fields = ["id", "companyName", "market", "CF_LAST", "CF_NETCHNG"];
var records = DataGenerator.generateRecords(fields, { numRows: 20 });
var configObj = {
columns: [
{name: "Id", field: fields[0], width: 50},
{name: "Company", field: fields[1]},
{name: "Market", field: fields[2], width: 100},
{name: "Last", field: fields[3], width: 80},
{name: "Net. Chng", field: fields[4], width: 80},
],
staticDataRows: records
};
var grid = document.getElementById("grid");
grid.config = configObj;
var rowId1, rowId2, rowId3;
document.getElementById("hide_btn").addEventListener("click", function() {
// Hide rows at index 0 and 1 (rowIds are "0" and "1" respectively since rows haven"t been sorted/filtered)
var dataView = grid.api.getDataView();
rowId1 = dataView.getRowId(0);
rowId2 = dataView.getRowId(1)
rowId3 = dataView.getRowId(2)
grid.api.hideRows([rowId1, rowId2, rowId3]);
});
document.getElementById("show_btn").addEventListener("click", function() {
grid.api.showRows([rowId2, rowId3]);
});
document.getElementById("clear_btn").addEventListener("click", function() {
// Unhide all currently hidden rows
grid.api.unhideAllRows();
});
</code></pre>
</code-sandbox>