Skip to content

Commit 3be29c9

Browse files
author
pipeline
committed
feature(EJ2-3785): Merged the ComboBox to Master branch
1 parent 0c0910d commit 3be29c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+868
-170
lines changed

src/combobox/cascading-plnkr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"common/shared.module":"import { NgModule } from '@angular/core';\nimport { ButtonModule } from '@syncfusion/ej2-ng-buttons';\nimport { ListViewModule } from '@syncfusion/ej2-ng-lists';\nimport { DropDownListModule } from '@syncfusion/ej2-ng-dropdowns';\n\n\n@NgModule({\n imports: [\n ButtonModule,\n ListViewModule,\n DropDownListModule\n ],\n \n exports: [\n ButtonModule,\n ListViewModule,\n DropDownListModule\n ]\n})\nexport class SharedModule { }\n","app.module":"import { CascadingComboBoxComponent } from './cascading.component';\nimport { HttpModule, JsonpModule } from '@angular/http';\nimport { BrowserModule } from '@angular/platform-browser';\nimport 'rxjs/add/operator/map';\nimport { NgModule, ModuleWithProviders, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\n\nimport { ComboBoxModule } from '@syncfusion/ej2-ng-dropdowns';\nimport { CheckBoxModule } from '@syncfusion/ej2-ng-buttons';\nimport { FormsModule } from '@angular/forms';\n\n\n\n\n\n\nimport { SharedModule } from './common/shared.module';\n\n\n\n\n@NgModule({\n imports: [ComboBoxModule, SharedModule, CheckBoxModule, FormsModule, HttpModule, JsonpModule, BrowserModule],\ndeclarations: [CascadingComboBoxComponent],\nbootstrap: [CascadingComboBoxComponent]\n})\nexport class AppModule { }","cascading.component":"/**\n * ComboBox Cascading Sample\n */\nimport { Component, ViewChild } from '@angular/core';\nimport { Query } from '@syncfusion/ej2-data';\nimport { ComboBoxComponent } from '@syncfusion/ej2-ng-dropdowns';\n\n@Component({\n selector: 'control-content',\n templateUrl: 'cascading.html',\n styleUrls: ['combobox.css']\n})\n\nexport class CascadingComboBoxComponent {\n public country: { [key: string]: Object }[] = [\n { countryName: 'Australia', countryId: '2' },\n { countryName: 'United States', countryId: '1' }\n ];\n public state: { [key: string]: Object }[] = [\n { stateName: 'New York', countryId: '1', stateId: '101' },\n { stateName: 'Queensland', countryId: '2', stateId: '104' },\n { stateName: 'Tasmania ', countryId: '2', stateId: '105' },\n { stateName: 'Victoria', countryId: '2', stateId: '106' },\n { stateName: 'Virginia ', countryId: '1', stateId: '102' },\n { stateName: 'Washington', countryId: '1', stateId: '103' }\n ];\n public cities: { [key: string]: Object }[] = [\n { cityName: 'Aberdeen', stateId: '103', cityId: 207 },\n { cityName: 'Alexandria', stateId: '102', cityId: 204 },\n { cityName: 'Albany', stateId: '101', cityId: 201 },\n { cityName: 'Beacon ', stateId: '101', cityId: 202 },\n { cityName: 'Brisbane ', stateId: '104', cityId: 211 },\n { cityName: 'Cairns', stateId: '104', cityId: 212 },\n { cityName: 'Colville ', stateId: '103', cityId: 208 },\n { cityName: 'Devonport', stateId: '105', cityId: 215 },\n { cityName: 'Emporia', stateId: '102', cityId: 206 },\n { cityName: 'Geelong', stateId: '106', cityId: 218 },\n { cityName: 'Hampton ', stateId: '102', cityId: 205 },\n { cityName: 'Healesville ', stateId: '106', cityId: 217 },\n { cityName: 'Hobart', stateId: '105', cityId: 213 },\n { cityName: 'Launceston ', stateId: '105', cityId: 214 },\n { cityName: 'Lockport', stateId: '101', cityId: 203 },\n { cityName: 'Melbourne', stateId: '106', cityId: 216 },\n { cityName: 'Pasco', stateId: '103', cityId: 209 },\n { cityName: 'Townsville', stateId: '104', cityId: 210 }\n ];\n public countryFields: Object = { value: 'countryId', text: 'countryName' };\n public stateFields: Object = { value: 'stateId', text: 'stateName' };\n public cityFields: Object = { text: 'cityName', value: 'cityId' };\n public countryWaterMark: string = 'Select a country';\n public stateWaterMark: string = 'Select a state';\n public cityWaterMark: string = 'Select a city';\n @ViewChild('countryList')\n public countryObj: ComboBoxComponent;\n @ViewChild('stateList')\n public stateObj: ComboBoxComponent;\n @ViewChild('cityList')\n public cityObj: ComboBoxComponent;\n public onChange1(): void {\n if (this.countryObj.value === null) {\n this.stateObj.enabled = false;\n this.cityObj.enabled = false;\n this.stateObj.value = null;\n this.cityObj.value = null;\n } else {\n this.stateObj.enabled = true;\n let tempQuery: Query = new Query().where('countryId', 'equal', this.countryObj.value);\n this.stateObj.query = tempQuery;\n this.stateObj.value = null;\n this.cityObj.value = null;\n this.cityObj.enabled = false;\n }\n this.stateObj.dataBind();\n this.cityObj.dataBind();\n }\n public onChange2(): void {\n if (this.stateObj.value === null) {\n this.cityObj.enabled = false;\n this.cityObj.value = null;\n } else {\n this.cityObj.enabled = true;\n let tempQuery: Query = new Query().where('stateId', 'equal', this.stateObj.value);\n this.cityObj.query = tempQuery;\n this.cityObj.value = null;\n }\n this.cityObj.dataBind();\n }\n}","cascading.html":"<div class=\"control-section\">\n <div class='control-wrapper' style='width: 250px; margin: 0 auto'>\n <div class=\"padding-top\" style='padding-top: 35px;'>\n <ej-combobox #countryList id='country' [dataSource]='country' [fields]='countryFields' (change)='onChange1()' [allowCustom]='false'\n [placeholder]='countryWaterMark'></ej-combobox>\n </div>\n <div class=\"padding-top\" style='padding-top: 35px;'>\n <ej-combobox #stateList id='state' [dataSource]='state' [fields]='stateFields' (change)='onChange2()' [allowCustom]='false'\n [placeholder]='stateWaterMark' [enabled]='false'></ej-combobox>\n </div>\n <div class=\"padding-top\" style='padding-top: 35px;'>\n <ej-combobox #cityList id='city' [dataSource]='cities' [fields]='cityFields' [placeholder]='cityWaterMark' [allowCustom]='false'\n [enabled]='false'></ej-combobox>\n </div>\n </div>\n</div>\n","combobox.css":".control-section {\n max-width: 350px;\n margin: 0 auto;\n}","index.html":"<!DOCTYPE html>\n<html>\n \n <head>\n <meta name=\"author\" content=\"Syncfusion\" />\n <link href=\"http://npmci.syncfusion.com/packages/production/material.css\" rel=\"stylesheet\" />\n <script src=\"https://unpkg.com/core-js/client/shim.min.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.min.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/zone.js/0.6.25/zone.min.js\"></script>\n <script src=\"https://unpkg.com/[email protected]\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js\"></script>\n <script src=\"systemjs.config.js\"></script>\n </head>\n \n <body>\n <control-content>\n <div id='loader'>Loading...</div>\n </control-content>\n </body>\n \n </html>\n ","systemjs.config.js":"System.config({\n transpiler: \"typescript\",\n typescriptOptions: {\n compilerOptions: {\n target: \"umd\",\n module: \"commonjs\",\n moduleResolution: \"node\",\n emitDecoratorMetadata: true,\n experimentalDecorators: true\n }\n },\n paths: {\n \"syncfusion:\": \"http://npmci.syncfusion.com/packages/production/\",\n \"angular:\": \"https://unpkg.com/@angular/\"\n },\n map: {\n main: 'main.ts',\n typescript: \"https://unpkg.com/[email protected]/lib/typescript.js\",\n \"plugin-json\":\"https://cdnjs.cloudflare.com/ajax/libs/systemjs-plugin-json/0.3.0/json.min.js\",\n \"@syncfusion/ej2-base\": \"syncfusion:ej2-base/dist/ej2-base.umd.min.js\",\n \"@syncfusion/ej2-buttons\": \"syncfusion:ej2-buttons/dist/ej2-buttons.umd.min.js\",\n \"@syncfusion/ej2-calendars\": \"syncfusion:ej2-calendars/dist/ej2-calendars.umd.min.js\",\n \"@syncfusion/ej2-charts\": \"syncfusion:ej2-charts/dist/ej2-charts.umd.min.js\",\n \"@syncfusion/ej2-circulargauge\": \"syncfusion:ej2-circulargauge/dist/ej2-circulargauge.umd.min.js\",\n \"@syncfusion/ej2-data\": \"syncfusion:ej2-data/dist/ej2-data.umd.min.js\",\n \"@syncfusion/ej2-dropdowns\": \"syncfusion:ej2-dropdowns/dist/ej2-dropdowns.umd.min.js\",\n \"@syncfusion/ej2-grids\": \"syncfusion:ej2-grids/dist/ej2-grids.umd.min.js\",\n \"@syncfusion/ej2-inputs\": \"syncfusion:ej2-inputs/dist/ej2-inputs.umd.min.js\",\n \"@syncfusion/ej2-lists\": \"syncfusion:ej2-lists/dist/ej2-lists.umd.min.js\",\n \"@syncfusion/ej2-navigations\": \"syncfusion:ej2-navigations/dist/ej2-navigations.umd.min.js\",\n \"@syncfusion/ej2-popups\": \"syncfusion:ej2-popups/dist/ej2-popups.umd.min.js\",\n \"@syncfusion/ej2-lineargauge\": \"syncfusion:ej2-lineargauge/dist/ej2-lineargauge.umd.min.js\",\n\n \"@syncfusion/ej2-ng-base\": \"syncfusion:ej2-ng-base/dist/ej2-ng-base.umd.min.js\",\n \"@syncfusion/ej2-ng-buttons\": \"syncfusion:ej2-ng-buttons/dist/ej2-ng-buttons.umd.min.js\",\n \"@syncfusion/ej2-ng-calendars\": \"syncfusion:ej2-ng-calendars/dist/ej2-ng-calendars.umd.min.js\",\n \"@syncfusion/ej2-ng-charts\": \"syncfusion:ej2-ng-charts/dist/ej2-ng-charts.umd.min.js\",\n \"@syncfusion/ej2-ng-circulargauge\": \"syncfusion:ej2-ng-circulargauge/dist/ej2-ng-circulargauge.umd.min.js\",\n \"@syncfusion/ej2-ng-data\": \"syncfusion:ej2-ng-data/dist/ej2-ng-data.umd.min.js\",\n \"@syncfusion/ej2-ng-dropdowns\": \"syncfusion:ej2-ng-dropdowns/dist/ej2-ng-dropdowns.umd.min.js\",\n \"@syncfusion/ej2-ng-grids\": \"syncfusion:ej2-ng-grids/dist/ej2-ng-grids.umd.min.js\",\n \"@syncfusion/ej2-ng-inputs\": \"syncfusion:ej2-ng-inputs/dist/ej2-ng-inputs.umd.min.js\",\n \"@syncfusion/ej2-ng-lists\": \"syncfusion:ej2-ng-lists/dist/ej2-ng-lists.umd.min.js\",\n \"@syncfusion/ej2-ng-navigations\": \"syncfusion:ej2-ng-navigations/dist/ej2-ng-navigations.umd.min.js\",\n \"@syncfusion/ej2-ng-popups\": \"syncfusion:ej2-ng-popups/dist/ej2-ng-popups.umd.min.js\",\n \"@syncfusion/ej2-ng-lineargauge\": \"syncfusion:ej2-ng-lineargauge/dist/ej2-ng-lineargauge.umd.min.js\",\n\n '@angular/core': 'angular:core/bundles/core.umd.js',\n '@angular/common': 'angular:common/bundles/common.umd.js',\n '@angular/compiler': 'angular:compiler/bundles/compiler.umd.js',\n '@angular/http': 'angular:http/bundles/http.umd.js',\n '@angular/forms': 'angular:forms/bundles/forms.umd.js',\n '@angular/router': 'angular:router/bundles/router.umd.js',\n '@angular/platform-browser': 'angular:platform-browser/bundles/platform-browser.umd.js',\n '@angular/platform-browser-dynamic': 'angular:platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',\n '@angular/material': 'angular:material/bundles/material.umd.js',\n 'rxjs': 'https://unpkg.com/rxjs'\n },\n meta: { \n '*.json': { loader: 'plugin-json' }\n }\n});\n\nSystem.import('main.ts').catch(console.error.bind(console));\n","main.ts":"import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\nimport { enableProdMode } from '@angular/core';\nimport { AppModule } from './app.module';\nimport { enableRipple } from '@syncfusion/ej2-base';\n\nenableRipple(true);\n\nenableProdMode();\nplatformBrowserDynamic().bootstrapModule(AppModule);"}

src/combobox/cascading.component.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* ComboBox Cascading Sample
3+
*/
4+
import { Component, ViewChild } from '@angular/core';
5+
import { Query } from '@syncfusion/ej2-data';
6+
import { ComboBoxComponent } from '@syncfusion/ej2-ng-dropdowns';
7+
8+
@Component({
9+
selector: 'control-content',
10+
templateUrl: 'cascading.html',
11+
styleUrls: ['combobox.css']
12+
})
13+
14+
export class CascadingComboBoxComponent {
15+
public country: { [key: string]: Object }[] = [
16+
{ countryName: 'Australia', countryId: '2' },
17+
{ countryName: 'United States', countryId: '1' }
18+
];
19+
public state: { [key: string]: Object }[] = [
20+
{ stateName: 'New York', countryId: '1', stateId: '101' },
21+
{ stateName: 'Queensland', countryId: '2', stateId: '104' },
22+
{ stateName: 'Tasmania ', countryId: '2', stateId: '105' },
23+
{ stateName: 'Victoria', countryId: '2', stateId: '106' },
24+
{ stateName: 'Virginia ', countryId: '1', stateId: '102' },
25+
{ stateName: 'Washington', countryId: '1', stateId: '103' }
26+
];
27+
public cities: { [key: string]: Object }[] = [
28+
{ cityName: 'Aberdeen', stateId: '103', cityId: 207 },
29+
{ cityName: 'Alexandria', stateId: '102', cityId: 204 },
30+
{ cityName: 'Albany', stateId: '101', cityId: 201 },
31+
{ cityName: 'Beacon ', stateId: '101', cityId: 202 },
32+
{ cityName: 'Brisbane ', stateId: '104', cityId: 211 },
33+
{ cityName: 'Cairns', stateId: '104', cityId: 212 },
34+
{ cityName: 'Colville ', stateId: '103', cityId: 208 },
35+
{ cityName: 'Devonport', stateId: '105', cityId: 215 },
36+
{ cityName: 'Emporia', stateId: '102', cityId: 206 },
37+
{ cityName: 'Geelong', stateId: '106', cityId: 218 },
38+
{ cityName: 'Hampton ', stateId: '102', cityId: 205 },
39+
{ cityName: 'Healesville ', stateId: '106', cityId: 217 },
40+
{ cityName: 'Hobart', stateId: '105', cityId: 213 },
41+
{ cityName: 'Launceston ', stateId: '105', cityId: 214 },
42+
{ cityName: 'Lockport', stateId: '101', cityId: 203 },
43+
{ cityName: 'Melbourne', stateId: '106', cityId: 216 },
44+
{ cityName: 'Pasco', stateId: '103', cityId: 209 },
45+
{ cityName: 'Townsville', stateId: '104', cityId: 210 }
46+
];
47+
public countryFields: Object = { value: 'countryId', text: 'countryName' };
48+
public stateFields: Object = { value: 'stateId', text: 'stateName' };
49+
public cityFields: Object = { text: 'cityName', value: 'cityId' };
50+
public countryWaterMark: string = 'Select a country';
51+
public stateWaterMark: string = 'Select a state';
52+
public cityWaterMark: string = 'Select a city';
53+
@ViewChild('countryList')
54+
public countryObj: ComboBoxComponent;
55+
@ViewChild('stateList')
56+
public stateObj: ComboBoxComponent;
57+
@ViewChild('cityList')
58+
public cityObj: ComboBoxComponent;
59+
public onChange1(): void {
60+
if (this.countryObj.value === null) {
61+
this.stateObj.enabled = false;
62+
this.cityObj.enabled = false;
63+
this.stateObj.value = null;
64+
this.cityObj.value = null;
65+
} else {
66+
this.stateObj.enabled = true;
67+
let tempQuery: Query = new Query().where('countryId', 'equal', this.countryObj.value);
68+
this.stateObj.query = tempQuery;
69+
this.stateObj.value = null;
70+
this.cityObj.value = null;
71+
this.cityObj.enabled = false;
72+
}
73+
this.stateObj.dataBind();
74+
this.cityObj.dataBind();
75+
}
76+
public onChange2(): void {
77+
if (this.stateObj.value === null) {
78+
this.cityObj.enabled = false;
79+
this.cityObj.value = null;
80+
} else {
81+
this.cityObj.enabled = true;
82+
let tempQuery: Query = new Query().where('stateId', 'equal', this.stateObj.value);
83+
this.cityObj.query = tempQuery;
84+
this.cityObj.value = null;
85+
}
86+
this.cityObj.dataBind();
87+
}
88+
}

src/combobox/cascading.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div class="control-section">
2+
<div class='control-wrapper' style='width: 250px; margin: 0 auto'>
3+
<div class="padding-top" style='padding-top: 35px;'>
4+
<ej-combobox #countryList id='country' [dataSource]='country' [fields]='countryFields' (change)='onChange1()' [allowCustom]='false'
5+
[placeholder]='countryWaterMark'></ej-combobox>
6+
</div>
7+
<div class="padding-top" style='padding-top: 35px;'>
8+
<ej-combobox #stateList id='state' [dataSource]='state' [fields]='stateFields' (change)='onChange2()' [allowCustom]='false'
9+
[placeholder]='stateWaterMark' [enabled]='false'></ej-combobox>
10+
</div>
11+
<div class="padding-top" style='padding-top: 35px;'>
12+
<ej-combobox #cityList id='city' [dataSource]='cities' [fields]='cityFields' [placeholder]='cityWaterMark' [allowCustom]='false'
13+
[enabled]='false'></ej-combobox>
14+
</div>
15+
</div>
16+
</div>
17+
18+
<div id="description">
19+
<p>The <code>Cascading</code> ComboBox is the series of ComboBox, where the value of one ComboBox depends on the another
20+
ComboBox value. This can be configured by making use of the <code>change</code> event of parent ComboBox. Within
21+
that change event handler, you should load the data to child ComboBox based on selected value of parent ComboBox.</p>
22+
23+
<p>In this sample, if a country is selected from countries ComboBox, then respective states will load in second ComboBox
24+
and the same has done between states and cities ComboBox.</p>
25+
26+
<p> More information on the Cascading feature configuration can be found in this
27+
<a href="../documentation/combo-box/how-to.html#configure-the-cascading-combobox" target="_blank"> documentation section</a>.
28+
</p>
29+
</div>

src/combobox/combobox.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.control-section {
2+
max-width: 350px;
3+
margin: 0 auto;
4+
}

src/combobox/combobox.module.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { NgModule, ModuleWithProviders, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
import { ComboBoxModule } from '@syncfusion/ej2-ng-dropdowns';
4+
import { CheckBoxModule } from '@syncfusion/ej2-ng-buttons';
5+
import { FormsModule } from '@angular/forms';
6+
import { DefaultComboBoxComponent } from './default.component';
7+
import { GroupAndIconComboBoxComponent } from './groupingicon.component';
8+
import { DataBindingComboBoxComponent } from './databinding.component';
9+
import { TemplateComboBoxComponent } from './template.component';
10+
import { CascadingComboBoxComponent } from './cascading.component';
11+
import { FilteringComboBoxComponent } from './filtering.component';
12+
import { SharedModule } from '../common/shared.module';
13+
export const comboboxAppRoutes: Object[] = [
14+
{ path: ':theme/combobox/default', component: DefaultComboBoxComponent, name: 'Default Functionalities', category: 'ComboBox' },
15+
{ path: ':theme/combobox/groupingicon', component: GroupAndIconComboBoxComponent, name: 'Grouping and Icons', category: 'ComboBox' },
16+
{ path: ':theme/combobox/databinding', component: DataBindingComboBoxComponent, name: 'Data Binding', category: 'ComboBox' },
17+
{ path: ':theme/combobox/template', component: TemplateComboBoxComponent, name: 'Template', category: 'ComboBox' },
18+
{ path: ':theme/combobox/filtering', component: FilteringComboBoxComponent, name: 'Filtering', category: 'ComboBox' },
19+
{ path: ':theme/combobox/cascading', component: CascadingComboBoxComponent, name: 'Cascading', category: 'ComboBox' }
20+
21+
];
22+
23+
export const ComboBoxRouter: ModuleWithProviders = RouterModule.forChild(comboboxAppRoutes);
24+
25+
@NgModule({
26+
imports: [ComboBoxRouter, ComboBoxModule, SharedModule, CheckBoxModule, FormsModule],
27+
declarations: [
28+
DefaultComboBoxComponent,
29+
GroupAndIconComboBoxComponent,
30+
DataBindingComboBoxComponent,
31+
TemplateComboBoxComponent,
32+
CascadingComboBoxComponent,
33+
FilteringComboBoxComponent
34+
],
35+
schemas: [CUSTOM_ELEMENTS_SCHEMA]
36+
})
37+
export class ComboBoxSampleModule {
38+
}

0 commit comments

Comments
 (0)