forked from syncfusion/ej2-aspnetcore-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTileView.cshtml
469 lines (444 loc) · 21 KB
/
TileView.cshtml
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
@using Syncfusion.EJ2
<script id="card_template" type="text/x-template">
<div class="e-card ${if(isHorizontal)} e-card-horizontal ${/if}">
${if(cardImage)}
<div class="e-card-image" style="background-image:url(${cardImage.url})">
${if(cardImage.title)}
<div class="e-card-title"> ${cardImage.title} </div>
${/if}
</div>
${/if} ${if(cardTitle)}
<div class="e-card-title"> ${cardTitle} </div>
${/if} ${if(header_title || header_subtitle || header_img)}
<div class="e-card-header">
${if(header_img)}
<div class="e-card-header-image ${if(header_img.isRounded)} e-card-corner ${/if}" style="background-image:url(${header_img.url})"></div>
${/if} ${if(header_title || header_subtitle)}
<div class="e-card-header-caption">
${if(header_title)}
<div class="e-card-header-title">${header_title}</div>${/if} ${if(header_subtitle)}
<div class="e-card-sub-title">${header_subtitle}</div>${/if}
</div>
${/if}
</div>
${/if} ${if(cardContent)}
<div class="e-card-content"> ${cardContent} </div>
${/if} ${if(card_action_btn)}
<div class="e-card-actions ${if(card_action_btn.isVertical)} e-card-vertical ${/if}">
${for(action_btn of card_action_btn.action_btns)} ${if(action_btn.tag === 'a')}
<a href="${action_btn.href}" target="${action_btn.target}">${action_btn.text}</a>
${else}
<button class="e-card-btn">${action_btn.text}</button>
${/if} ${/for}
</div>
${/if}
</div>
</script>
@section ControlsSection{
<div class="control-section card-control-section tile_layout">
<div class="row filter">
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div class="e-float-input e-input-group">
<input type="text" required="" id="search_Card">
<span class="e-float-line"></span>
<label class="e-float-text" style="font-size:14px">Enter text to search</label>
<span class="e-clear-icon"></span>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6 tile_search">
<input type="text" id="local">
</div>
</div>
<div class="row e-card-layout" style="text-align:center;">
<div class="row">
<div class="row error" style="display:none;min-height:150px">
<div class="e-error-content" style="margin:auto;height:inherit;font-size:18px;font-weight:500;color:inherit">No results found. Please try a different search.</div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<!-- Tile View Layout -->
<div id="card_sample_1" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_2" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_3" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_4" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_5" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_6" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_7" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_8" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_9" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_10" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_11" class="card_sample"></div>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
<div id="card_sample_12" class="card_sample"></div>
</div>
</div>
</div>
<div id="source_link">
Source:
<a href="https://www.syncfusion.com/ebooks/" target="_blank">https://www.syncfusion.com/ebooks</a>
</div>
</div>
}
@section ActionDescription{
<p>
This sample demonstrates filter and search of the <code>card</code> based on categories, and text containing the card. You can use search box to search cards, and you can filter choosing categories in multi-select component.
</p>
}
@section Description{
<p>
Card is a small container in which user can show defined content in specific structure and it is flexible and extensible. This sample demonstrates to render the <code>Card</code> Using <a target="_blank" href="https://ej2.syncfusion.com/documentation/common/template-engine/"> Template Engine</a> and it can be filtered based on <a target="_blank" href="https://ej2.syncfusion.com/documentation/data/getting-started/"> data Manager </a>.
</p>
<p>
More information about Card can be found in this <a target="_blank" href="https://ej2.syncfusion.com/aspnetcore/documentation/card/getting-started-asp-core/"> documentation </a> section.
</p>
}
@section Meta{
<meta name="description" content="The sample demonstrates how to design tile-view with filtering and searching using a template engine, data manager, and card component in ASP.NET Core platform." />
}
<style>
/* Tile view card customization */
.tile_layout.card-control-section .row.filter .tile_search {
justify-content: flex-end;
}
.tile_layout.card-control-section .row .e-card {
text-align: left;
}
.tile_layout.card-control-section .control-wrapper {
padding: 0 20px;
}
.tile_layout.card-control-section .row.filter {
margin: 0;
}
.tile_layout.card-control-section .e-card .e-card-actions a {
border: 1px solid;
display: block;
margin: auto;
width: 100px;
border-radius: inherit;
}
.tile_layout.card-control-section .e-card .e-card-header .e-card-header-caption .e-card-header-title {
font-size: 18px;
}
.tile_layout.card-control-section .e-card .e-card-image {
height: 165px;
width: 200px;
}
.tile_layout.card-control-section .row.filter .col-xs-6.col-sm-6.col-lg-6.col-md-6 {
display: inline-flex;
flex-direction: column;
width: 100%;
}
.tile_layout.card-control-section .col-xs-6.col-sm-6.col-lg-6.col-md-6 {
width: 100%;
padding: 10px;
}
.card-control-section.tile_layout .e-card-layout {
margin: auto;
max-width: 190px;
}
#source_link {
float: right;
margin-right: 10px;
}
@@media screen and (max-width: 768px) {
#source_link {
margin-right: 0px;
}
}
@@media (min-width: 960px) {
.tile_layout.card-control-section .col-xs-6.col-sm-6.col-lg-6.col-md-6 {
width: 25%;
}
.card-control-section.tile_layout .e-card-layout {
max-width: 850px;
}
}
@@media (min-width: 540px) {
.tile_layout.card-control-section .row.filter {
display: flex
}
.tile_layout.card-control-section .e-card .e-card-content {
min-height: 170px;
max-height: 170px;
}
}
@@media (max-width: 960px) and (min-width: 540px) {
.tile_layout.card-control-section .col-xs-6.col-sm-6.col-lg-6.col-md-6 {
width: 50%;
}
.card-control-section.tile_layout .e-card-layout {
max-width: 410px;
}
}
</style>
@section Scripts {
<script type="text/javascript">
window.cardBook = [
{
header_title: ' ASP.NET MVC',
header_subtitle: 'Nick Harrison',
cardImage: { url: '../css/card/Tile_1.png', tag: 'server' },
cardContent: 'ASP.NET Model View Controller design pattern to keep the data, views, and logic clearly separated in apps.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/ASPNET_MVC_Succinctly', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: ' Node.js',
header_subtitle: 'Emanuele DelBono ',
cardImage: { url: '../css/card/Tile_2.png', tag: 'client' },
cardContent: 'Node.js is a wildly popular platform for writing web applications that has revolutionized web development in many ways.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/nodejs', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: ' React.js',
header_subtitle: 'Dmitri Nesteruk',
cardImage: { url: '../css/card/Tile_3.png', tag: 'client' },
cardContent: 'React is a JavaScript library that has revolutionized how developers design and think about views in web applications.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/reactjs_succinctly', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: ' TypeScript',
header_subtitle: 'Steve Fenton',
cardImage: { url: '../css/card/Tile_4.png', tag: 'client' },
cardContent: 'Microsoft TypeScript extends many familiar features of .NET programming to JavaScript.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/typescript', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: ' PHP',
header_subtitle: 'Jose Roberto Olivas Mendoza',
cardImage: { url: '../css/card/Tile_5.png', tag: 'server' },
cardContent: 'Known for its straightforward simplicity, PHP is an open source, general-purpose scripting language oriented for web development.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/php_succinctly', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: ' CSS3',
header_subtitle: 'Peter Shaw',
cardImage: { url: '../css/card/Tile_6.png', tag: 'ui' },
cardContent: 'In CSS3 Succinctly, author Peter Shaw provides an overview of the latest features available for custom cascading style sheets.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/css3', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: ' ASP.NET Core',
header_subtitle: 'Simone Chiaretta and Ugo Lattanzi',
cardImage: { url: '../css/card/Tile_7.png', tag: 'server' },
cardContent: 'In ASP.NET Core Succinctly, seasoned authors Simone Chiaretta and Ugo Lattanzi update you on all the advances provided by Microsoft’s landmark framework.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/asp_net_core_succinctly', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: 'Aurelia',
header_subtitle: 'Matthew Duffield',
cardImage: { url: '../css/card/Tile_8.png', tag: 'client' },
cardContent: 'Aurelia is a relatively new, open-source JavaScript library/framework that simplifies the creation of web-based applications.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/aurelia_succinctly', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: 'ECMAScript 6 ',
header_subtitle: 'Matthew Duffield',
cardImage: { url: '../css/card/Tile_9.png', tag: 'client' },
cardContent: 'ECMAScript 6 (ES6), also known as ECMAScript 2015, brings new functionality and features to the table that developers have been wanting for a long time.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/ecmascript_6_succinctly', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: 'JavaScript',
header_subtitle: 'Cody Lindley',
cardImage: { url: '../css/card/Tile_10.png', tag: 'client' },
cardContent: 'JavaScript Succinctly was written to give readers an accurate, concise examination of JavaScript objects and their supporting nuances.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/javascript', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: 'Knockout.js',
header_subtitle: 'Ryan Hodson',
cardImage: { url: '../css/card/Tile_11.png', tag: 'client' },
cardContent: 'Knockout.js Succinctly is intended for professional web developers who need to build dynamic, scalable user interfaces with minimal code.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/knockoutjs', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
{
header_title: 'Angular 2',
header_subtitle: 'Joseph D. Booth',
cardImage: { url: '../css/card/Tile_12.png', tag: 'client' },
cardContent: 'Angular 2 is a massively popular JavaScript framework built to take advantage of component development in web apps.',
card_action_btn: {
action_btns: [{ tag: 'a', href: 'https://www.syncfusion.com/ebooks/angular2_succinctly', target: '_blank', text: 'Read More' }],
isVertical: true
},
isHorizontal: false
},
];
var cardTemplateFn = ej.base.compile(document.getElementById('card_template').innerHTML.trim());
var card;
var cardEle;
var cardObj = window.cardBook;
var data = [];
var multiSelectData = [];
var searchData = [];
var searchValCount = 0;
var filterCategory = [{ Name: 'Client-Side', Code: 'client' }, { Name: 'Server-Side', Code: 'server' }, { Name: 'Front-End', Code: 'ui' }];
var emptyData = true;
cardRendering(cardObj);
var multiselectComp = new ej.dropdowns.MultiSelect({
dataSource: filterCategory,
fields: { text: 'Name', value: 'Code' },
placeholder: 'Search by categories',
tagging: multiSelectFun,
removed: multiSelectRemove,
});
multiselectComp.appendTo('#local');
function cardRendering(cardObj) {
var errorContent = document.querySelector('.tile_layout .row.error');
if (cardObj.length > 0) {
errorContent.style.display = 'none';
cardObj.forEach(function (data, index) {
card = cardTemplateFn(data);
cardEle = document.getElementById('card_sample_' + (++index));
if (cardEle) {
cardEle.appendChild(card[0]);
}
});
}
else {
errorContent.style.display = 'flex';
}
}
function destroyAllCard() {
var cards = document.querySelectorAll('.card-control-section .e-card');
[].slice.call(cards).forEach(function (el) {
ej.base.detach(el);
});
}
function multiSelectRemove(e) {
var cardDa = searchData.length > 0 ? searchData : (multiSelectData.length > 0 ? multiSelectData : cardObj);
if (multiselectComp.value && multiselectComp.value.length === 0 && searchValCount === 0) {
multiSelectData = cardDa;
destroyAllCard();
cardRendering(cardObj);
}
else if (multiselectComp.value.length === 0 && searchValCount > 0) {
searchFilter(document.getElementById('search_Card').value);
}
else if (multiselectComp.value.length === 0) {
destroyAllCard();
multiSelectData = cardDa;
cardRendering(cardDa);
}
else {
var keywords = e.itemData.Code.split(',');
var dublicate_1;
keywords.forEach(function (key) {
dublicate_1 = new ej.data.DataManager(cardObj).executeLocal(new ej.data.Query().where('cardImage.tag', 'Contains', key, true));
dublicate_1.forEach(function (da) {
if (cardDa.indexOf(da) !== -1) {
cardDa.splice(cardDa.indexOf(da), 1);
}
});
multiSelectData = cardDa;
});
destroyAllCard();
cardRendering(multiSelectData);
}
}
function multiSelectFun(e) {
var keywords = e.itemData.Code.split(',');
var dublicate;
var cardDa = searchData.length > 0 ? searchData : cardObj;
if (multiselectComp.value && multiselectComp.value.length === 0 && searchValCount === 0) {
multiSelectData = [];
}
keywords.forEach(function (key) {
dublicate = new ej.data.DataManager(cardDa).executeLocal(new ej.data.Query().where('cardImage.tag', 'Contains', key, true));
if (dublicate.length === 0) {
multiSelectData = [];
destroyAllCard();
return;
}
dublicate.forEach(function (da) {
if (multiSelectData.indexOf(da) === -1) {
multiSelectData.push(da);
}
});
});
destroyAllCard();
cardRendering(multiSelectData);
}
function searchFilter(key) {
searchValCount = key.length;
var predicate = new ej.data.Predicate('cardContent', 'Contains', key, true);
predicate = predicate.or('cardImage.title', 'Contains', key, true).or('header_title', 'Contains', key, true).or('header_subtitle', 'Contains', key, true);
var cardDa = (multiSelectData.length > 0 && multiselectComp.value.length > 0) ? multiSelectData : cardObj;
searchData = data = new ej.data.DataManager(cardDa).executeLocal(new ej.data.Query().where(predicate));
destroyAllCard();
cardRendering(data);
}
document.getElementById('search_Card').onkeyup = function (e) {
if (e.code === 'Tab' || e.code === 'Escape' || e.code === 'ShiftLeft' || (e.code === 'Backspace' && emptyData)) {
return;
}
var inputVal = e.target.value;
/*jshint -W030 */
inputVal.length === 0 ? emptyData = true : emptyData = false;
searchFilter(inputVal);
};
</script>
}