-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-152.html
195 lines (184 loc) · 17.5 KB
/
template-152.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<link rel="stylesheet" href="./resources/styles/elf-template.css">
<h1 id="column-format-dialog">Column Format Dialog</h1>
<p>The Column Format Dialog is a user-friendly interface for column display customization. It can format a column's value display from <code>General</code> to <code>Number</code>, <code>Scaled</code>, <code>Percent</code> or <code>Datetime</code>, and so on.</p>
<h2 id="features">Features</h2>
<ul>
<li>Value formatting: number, scaled, date and time, and FX formats</li>
<li>Heatmap</li>
<li>Conditional coloring</li>
<li>Colored texts and background</li>
</ul>
<h2 id="demo">Demo</h2>
<p><code>Right-click</code> on each column header to see the dialog.</p>
<code-sandbox hash="6421a6ee"><pre><code class="language-css">textarea {
width: 100%;
height: 100px;
}
efx-grid {
min-height: 500px;
}
html hr {
margin: 5px;
}
</code></pre>
<pre><code class="language-html">Language:
<select id="lang_selector">
<option value="en">English</option>
<option value="ja">Japanese</option>
<option value="de">German</option>
<option value="zh">Simplified Chinese</option>
<option value="zh-Hant">Traditional Chinese</option>
</select>
<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 columnFormattingExt = new ColumnFormatting();
var contextMenuExt = new ContextMenu();
var fields = ["companyName", "market", "CF_LAST", "CF_NETCHNG", "CF_VOLUME", "TR.IPODate"];
var records = DataGenerator.generateRecords(fields, { numRows: 10 });
var configObj = {
columns: [
{name: "Company", field: fields[0]},
{name: "Market", field: fields[1], width: 100},
{name: "Last", field: fields[2], width: 80, alignment: "right"},
{name: "Net. Chng", field: fields[3], width: 80, alignment: "right"},
{name: "Volume", field: fields[4], alignment: "right"},
{name: "IPO date", field: fields[5], width: 100}
],
staticDataRows: records,
contextMenu: {
items: {
MENU_1: {
text: "Format",
callback: function (e) {
var lang = document.getElementById("lang_selector").value;
columnFormattingExt.openDialog(e.colIndex, {
lang: lang
});
}
}
},
onMenu: function (e) {
e.menu.addItem("MENU_1");
}
},
extensions: [
columnFormattingExt,
contextMenuExt
]
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
</code-sandbox><blockquote>
<p>For more information about the extension see the <a href="#/extensions/tr-grid-column-formatting">Column Formatting Extension</a> page.</p>
</blockquote>
<h2 id="setup-guide">Setup guide</h2>
<p>First, let's import the modules.</p>
<pre><code class="language-js">// efx-grid
import "@refinitiv-ui/efx-grid";
import "@refinitiv-ui/efx-grid/themes/halo/light";
// extensions
import {
ConditionalColoring,
HeatMap,
TextFormatting,
ColumnFormatting
} from "@refinitiv-ui/efx-grid/extensions";
// Column Formatting Dialog module
import "@refinitiv-ui/efx-grid/column-format-dialog";
import "@refinitiv-ui/efx-grid/column-format-dialog/themes/halo/light";
</code></pre>
<p>Create a new Column Formatting Extension instance and push it to an <code>extensions</code> configuration.</p>
<pre><code class="language-js">var cfe = new ColumnFormatting();
var configObj = {
extensions: [
cfe,
new TextFormatting(),
new HeatMap(),
new ConditionalColoring()
],
columns: columns, // Columns config
staticDataRows: dataRows
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
<p>To open the dialog, you need to call <code>openDialog()</code> method on the extension object.</p>
<pre><code class="language-js">cfe.openDialog(0); // Change "0" to any column index.
// Or open the dialog with specific configuration.
cfe.openDialog(0, {
supportDisplayStyleOptions: {
fx: true,
},
supportValueFormatOptions: {
fx: true
}
supportHighlightApplyToSwitch: true,
data: {
"fieldList": [{"value": "col1"}, {"value": "col2"}, {"value": "col3"}, {"value": "col4"}, {"value": "col5"}],
"valueFormatTab": {"formatType": "general"},
"colorTextTab": {"colorText": {"field": "col2"}},
"displayStyleTab": {"general": {"alignment": "center"}, "mode": "general"},
"fieldDataType": "general"
},
fields: ["intCol", "strCol", "boolCol", "floatCol", "dateCol"],
});
</code></pre>
<h2 id="changing-language">Changing Language</h2>
<p>For more information about internationalization and how is it applied in different contexts see <a href="#/widgets/language-support">Language Support</a>.</p>
<h2 id="using-with-context-menu-extension">Using with <a href="#/extensions/tr-grid-contextmenu">Context Menu Extension</a></h2>
<p>For most cases, you will want the dialog button to appear when the user right-clicks on the column header (known as the context menu).</p>
<p>To do this, simply import <code>Context Menu</code> extension and its configurations.</p>
<pre><code class="language-js">import {
ContextMenu,
ColumnFormatting,
TextFormatting,
HeatMap,
ConditionalColoring
} from "@refinitiv-ui/efx-grid/extensions";
var cfe = new ColumnFormatting();
var configObj = {
extensions: [
cfe,
new ContextMenu(),
new TextFormatting(),
new HeatMap(),
new ConditionalColoring()
],
columns: columns, // Columns config
staticDataRows: dataRows,
contextMenu: {
items: {
MENU_1: {
text: "Format",
callback: function (e) {
// Open the dialog when click on the "Format" menu
cfe.openDialog(e.colIndex);
}
},
},
onMenu: function (e) {
e.menu.addItem("MENU_1");
}
},
};
</code></pre>
<p>And that's it!</p>
<h2 style="margin-bottom:5px" id="api-refs">API Reference</h2>
<div id="elf-api-container"><div id="main-template" class="elf-template"> <section><header> <h1 class="subsection-title"><span class="attribs"><span class="type-signature"></span></span>ColumnFormatDialog<span class="signature">()</span><span class="type-signature"></span></h1> </header><article> <h3 class="subsection-title" id="type_definitions">Type Definitions</h3>
<div class="item"> <div class="item-type">typedef</div> <h4 class="name" id="~Config">Config</h4> <h5>Type:</h5> <span class="param-type">Object</span> <h5>Properties:</h5> <div class="props"><table> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> </td> <td class="description last">Context object indicating current states of the column</td> </tr> <tr> <td class="name"><code>supportHighlightApplyToSwitch</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">support HighlightApplyToSwitch</td> </tr> <tr> <td class="name"><code>supportValueFormatOptions</code></td> <td class="type"> <span class="param-type"><a href="#/widgets/column-format-dialog#~SupportValueFormatOptions">ColumnFormatDialog~SupportValueFormatOptions</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Support FxFormat</td> </tr> <tr> <td class="name"><code>supportDisplayStyleOptions</code></td> <td class="type"> <span class="param-type"><a href="#/widgets/column-format-dialog#~SupportDisplayStyleOptions">ColumnFormatDialog~SupportDisplayStyleOptions</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Support items in "Display Style" dropdown</td> </tr> <tr> <td class="name"><code>fields</code></td> <td class="type"> <span class="param-type">Array.<string></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">List of available fields to be shown in the dialog</td> </tr> <tr> <td class="name"><code>confirm</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Confirm event callback</td> </tr> <tr> <td class="name"><code>cancel</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Cancel event callback</td> </tr> </tbody></table></div><div class="details"> </div></div>
<div class="item"> <div class="item-type">typedef</div> <h4 class="name" id="~SupportDisplayStyleOptions">SupportDisplayStyleOptions</h4> <h5>Type:</h5> <span class="param-type">Object</span> <h5>Properties:</h5> <div class="props"><table> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>bar</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="description last">support "bar"</td> </tr> </tbody></table></div><div class="details"> </div></div>
<div class="item"> <div class="item-type">typedef</div> <h4 class="name" id="~SupportValueFormatOptions">SupportValueFormatOptions</h4> <h5>Type:</h5> <span class="param-type">Object</span> <h5>Properties:</h5> <div class="props"><table> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>fx</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="description last">support "fx"</td> </tr> </tbody></table></div><div class="details"> </div></div> <h3 class="subsection-title" id="methods">Methods</h3>
<div class="item"> <div class="item-type">function</div> <h4 class="name" id="hide"><span class="type-signature"></span>hide<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Hide the dialog </div> <div class="details"> </div> </div>
<div class="item"> <div class="item-type">function</div> <h4 class="name" id="init"><span class="type-signature"></span>init<span class="signature">(userConfig<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <h5>Parameters:</h5> <div class="params"> <div class="param"> <div class="name">userConfig</div> <div class="type"> <span class="param-type"><a href="#/widgets/column-format-dialog#~Config">ColumnFormatDialog~Config</a></span> </div> <div class="attributes"> <optional> </div> <div class="description"> Configuration object used to initialize dialog and populate data </div> </div> </div> <div class="details"> </div> </div>
<div class="item"> <div class="item-type">function</div> <h4 class="name" id="show"><span class="type-signature"></span>show<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Show the dialog </div> <div class="details"> </div> </div>
<div class="item"> <div class="item-type">function</div> <h4 class="name" id="updateDataWithAutosuggest"><span class="type-signature"></span>updateDataWithAutosuggest<span class="signature">(selectedItem, autoSuggest)</span><span class="type-signature"></span></h4> <h5>Parameters:</h5> <div class="params"> <div class="param"> <div class="name">selectedItem</div> <div class="type"> <span class="param-type">Object</span> </div> <div class="description"> autosuggest selection </div> </div> <div class="param"> <div class="name">autoSuggest</div> <div class="type"> <span class="param-type">Object</span> </div> <div class="description"> source autosuggest element </div> </div> </div> <div class="details"> </div> </div> </article></section></div></div>