-
Notifications
You must be signed in to change notification settings - Fork 0
/
template-102.html
52 lines (50 loc) · 2.99 KB
/
template-102.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
<h1 id="formatter-default">Formatter (default)</h1>
<p>Formatter is what Grid uses to render content. Grid's default formatter will render any data in plain text. When data is updated, Grid will bind the data from its own internal data source to render the data in plain text using the formatter. The data given to grid can be any data type.</p>
<blockquote>
<p>Note: The formatter will be repeatedly executed multiple times for every update and scrolling. </p>
</blockquote>
<p>Default rendering is already optimized for row virtualization. This means that grid uses the same text element to render different data for different rows. It should be fast enough to handle rendering a million of rows.</p>
<p>To update what is shown on the Grid, please use Grid's APIs to <a href="#/general-concept/accessing-data">manipulate the data</a> from the instance.</p>
<h2 id="example">Example</h2>
<code-sandbox hash="910e0fa0"><pre><code class="language-css">efx-grid {
height: 200px;
}
</code></pre>
<pre><code class="language-html"><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 = ["companyName", "market", "CF_LAST", "CF_NETCHNG", "industry"];
var records = DataGenerator.generateRecords(fields, { numRows: 40 });
var configObj = {
columns: [
{name: "Company", field: fields[0]},
{name: "Market", field: fields[1]},
{name: "Last", field: fields[2]},
{name: "Net. Chng", field: fields[3]},
{name: "Industry", field: fields[4]}
],
staticDataRows: records
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
</code-sandbox><h2 id="internal-default-formatter-implementation">Internal Default Formatter Implementation</h2>
<p>Internally, Grid implements the formatter as the following code: </p>
<pre><code class="language-js">var configObj = {
columns: [
{ binding: function(e){
e.cell.setContent(e.data);
}
}
]
};
</code></pre>
<h1 id="custom-formatter">Custom Formatter</h1>
<p>If we want anything other than simple text, we need to define a custom formatter. You can find more details about this in the <a href="#/rendering/custom-formatter">Custom Formatter section</a>.</p>