Skip to content

Instantly share code, notes, and snippets.

@gregoryagu
Forked from keerthanaRajendran/app.html
Last active April 4, 2019 23:53
Show Gist options
  • Save gregoryagu/b32a044be79b0cc21da78349c9f4d66e to your computer and use it in GitHub Desktop.
Save gregoryagu/b32a044be79b0cc21da78349c9f4d66e to your computer and use it in GitHub Desktop.
Dropdownlist : filtering DataSource on change event
<template>
<div class="container">
<div class="form-row">
<div class="col-6">
<fieldset class="form-group">
<label class="form-label semibold">Select Group</label>
<input type="text" id="selectGroup" ej-drop-down-list="e-width:100%;e-data-source.bind:groups;e-fields.bind:{ text: 'name', value: 'Id' };e-watermark-text.bind:'Select...';" e-on-change.trigger='onchange($event)' />
</fieldset>
</div>
<div class="col-6">
<fieldset class="form-group">
<label class="form-label semibold">Select Country</label>
<input type="text" id="selectCountry"
ej-drop-down-list="e-width:100%;e-data-source.two-way:filteredCountries;e-watermark-text.bind:'Select...';e-fields.bind: { text: 'name', value: 'Id' };" />
</fieldset>
</div>
</div>
</div>
</template>
export class EjDDLCheckBox {
groups = [{
Id: 'a',
name: "Group A"
}, {
Id: 'b',
name: "Group B"
}];
allCountries = [{
value: 11,
groupId: 'a',
name: "Algeria"
}, {
value: 12,
groupId: 'a',
name: "Armenia"
}, {
value: 13,
groupId: 'a',
name: "Bangladesh"
}, {
value: 15,
groupId: 'a',
name: "Denmark"
}, {
value: 24,
groupId: 'b',
name: "Singapore"
}, {
value: 25,
groupId: 'b',
name: "Thailand"
}, {
value: 26,
groupId: 'b',
name: "Ukraine"
}]
constructor() {
}
filteredCountries = [];
onchange(event) {
if (event.detail.value == "a") {
this.filteredCountries = this.allCountries.filter(a=> a.groupId === 'a');
}
else if (event.detail.value == "b") {
this.filteredCountries = this.allCountries.filter(a => a.groupId === 'b');
}
}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential Studio for JavaScript">
<meta name="author" content="Syncfusion">
<title>Untitled</title>
<!-- Essential Studio for JavaScript theme reference -->
<link rel="stylesheet" href="https://cdn.syncfusion.com/14.2.0.28/js/web/flat-azure/ej.web.all.min.css" />
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script>
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-syncfusion-bundles/0.0.1/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-syncfusion-bridge', syncfusion => syncfusion.useAll());
aurelia.start().then(a => a.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment