-
Notifications
You must be signed in to change notification settings - Fork 0
/
template-29.html
189 lines (175 loc) · 9.36 KB
/
template-29.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
<h1 id="column-moving">Column Moving</h1>
<h2 id="drag-and-drop">Drag and drop</h2>
<p>The ability of drag and drop column is enabled by default. But it can be turned off by setting <code>noColumnDragging</code> to <em>true</em>. The default value is <em>false</em>. </p>
<h3 id="drag-and-drop-to-move-a-column-example-default">Drag and drop to move a column example (default)</h3>
<code-sandbox hash="e43b0864"><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: 10 });
var configObj = {
columns: [
{name: "Company", field: fields[0]},
{name: "Market", field: fields[1], width: 100},
{name: "Last", field: fields[2], width: 80},
{name: "Net. Chng", field: fields[3], width: 80},
{name: "Industry", field: fields[4]}
],
staticDataRows: records
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
</code-sandbox><h3 id="disabled-drag-and-drop-example">Disabled drag and drop example</h3>
<code-sandbox hash="dbb479c"><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: 10 });
var configObj = {
noColumnDragging: true, // disabled column re-order
columns: [
{name: "Company", field: fields[0]},
{name: "Market", field: fields[1], width: 100},
{name: "Last", field: fields[2], width: 80},
{name: "Net. Chng", field: fields[3], width: 80},
{name: "Industry", field: fields[4]}
],
staticDataRows: records
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
</code-sandbox><h2 id="using-apis-to-move-a-column">Using APIs to move a column</h2>
<p>Columns can be moved using the <code>grid.api.moveColumnById(sourceColumn, destinationPosition)</code> API, which allows you to move specified column by index or id to the position before the specified destination. If the specified destination is invalid or doesnot exist, the column will be moved to the end of Grid.</p>
<p>To move multiple columns at once, use <code>reorderColumns</code> API. </p>
<p>See <a href="#/apis/rt-grid/grid">available APIs</a> for more details.</p>
<h3 id="example">Example</h3>
<code-sandbox hash="23cc81ae"><pre><code class="language-css">efx-grid {
height: 200px;
}
html hr {
margin: 5px;
}
button {
margin: 2px;
}
</code></pre>
<pre><code class="language-html"><big>Move</big>
<select id="source_sel"></select>
<big>to the position before</big>
<div id="destination_div"></div>
<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 = ["companyName", "market", "CF_LAST", "CF_NETCHNG", "industry"];
var colNames = ["Company", "Market", "Last", "Net. Chng", "Industry"];
var columns = fields.map(function(f, idx) {
var colName = colNames[idx];
var colId = "c" + idx;
return {
id: colId,
field: f,
name: colName
};
});
columns[1].width = 100;
columns[2].width = 80;
columns[3].width = 80;
columns.forEach(function(col, idx) {
var opt = document.createElement("option");
opt.value = col.id;
opt.textContent = col.name + " column";
if(col.name === "Industry") {
opt.selected = true;
}
source_sel.appendChild(opt);
var btn = document.createElement("button");
btn.colId = col.id;
btn.textContent = col.name;
btn.addEventListener("click", onClickMoveBtn);
destination_div.appendChild(btn);
});
var lastBtn = document.createElement("button");
lastBtn.textContent = "End of Grid";
lastBtn.addEventListener("click", onClickMoveBtn);
destination_div.appendChild(lastBtn);
function onClickMoveBtn(e) {
var btn = e.currentTarget;
var destId = btn.colId;
var sourceOpt = source_sel.selectedOptions[0];
var srcId = sourceOpt.value;
grid.api.moveColumnById(srcId, destId);
}
var records = DataGenerator.generateRecords(fields, { numRows: 5 });
var configObj = {
columns: columns,
staticDataRows: records
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
</code-sandbox><h2 id="preventing-a-column-from-moving">Preventing a column from moving</h2>
<p>By marking a column to be a <code>stationary</code> column, any column on the left and the stationary column will be locked in the position (i.e., columns cannot be moved). A column can still be added to or removed from the stationary section. Once stationary column is removed or unmarked as <code>stationary</code>, the columns in the section will be free to be moved. See <a href="#/apis/rt-grid/columndefinition">Column Definition</a> for more details of column options.</p>
<h3 id="example-1">Example</h3>
<code-sandbox hash="26f3381b"><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: 10 });
var configObj = {
columns: [
{name: "Company (stationary)", field: fields[0], stationary: true},
{name: "Market", field: fields[1], width: 100},
{name: "Last", field: fields[2], width: 80},
{name: "Net. Chng", field: fields[3], width: 80},
{name: "Industry", field: fields[4]}
],
staticDataRows: records,
extensions: [new Checkbox()]
};
var grid = document.getElementById("grid");
grid.config = configObj;
</code></pre>
</code-sandbox><p><br><br><br></p>