import { Component, OnInit } from '@angular/core';
import { SelectItem } from 'primeng/primeng';
import { AbstractControl, ReactiveFormsModule, FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { DataTableModule,SharedModule} from 'primeng/primeng';
import { AdvancePipe } from './advance.pipe';
import { CountryPipe } from './country.pipe';


@Component({
  selector: 'my-app',
  templateUrl: 'app/app.template.html',
  pipes: [AdvancePipe, CountryPipe]
})
export class AppComponent implements OnInit {
  
    filter0Form: FormGroup;
    filter1Form: FormGroup;
    filter2Form: FormGroup;
    filter3Form: FormGroup;
    countriesInFilterForm1: SelectItem [] = [];
    countriesInFilterForm2: SelectItem [] = [];
    countriesInFilterForm3: SelectItem [] = [];
    type: string;
    minimum: any;
     
    continents = 
              [
               { "name":"Europe", "countries": 
                  [
                    { "name":"UK"},
                    { "name":"France"},
                    { "name":"Germany"},
                    { "name":"Spain"},
                    { "name":"Portugal"},
                    { "name":"Switzerland"},
                    { "name":"Norway"}
                  ] 
               },
               { "name":"Asia", "countries": 
                  [
                    { "name":"Philippines"},
                    { "name":"India"},
                    { "name":"Japan"},
                    { "name":"China"},
                    { "name":"Taiwan"},
                    { "name":"South Korea"},
                    { "name":"Indonesia"}
                  ] 
               },
               { "name":"North America", "countries": 
                  [
                    { "name":"US"},
                    { "name":"Canada"},
                    { "name":"Mexico"}
                  ] 
               }
              ];
              
     persons: any [] = 
        [
          {
            "firstName": "paolo",
            "lastName":"revira",
            "age": "35",
            "height": '5.6',
            "salary":"20000",
            "continents": 
              [
               {"name":"Europe", "country": "UK" },
               {"name":"Asia", "country": "China" },
               {"name":"North America", "country": "US" }
              ]
          },
          {
            "firstName": "sarah",
            "lastName":"santos",
            "age": "31",
            "height": '5.8',
            "salary":"15000",
            "continents": 
              [
               {"name":"Europe", "country": "UK" },
               {"name":"Asia", "country": "China" },
               {"name":"North America", "country": "Canada" }
              ]
          },
          {
            "firstName": "arj",
            "lastName":"dela cruz",
            "age": "20",
            "height": '5.6',
            "salary":"20000",
            "continents": 
              [
               {"name":"Europe", "country": "UK" },
               {"name":"Asia", "country": "Japan" },
               {"name":"North America", "country": "Mexico" }
              ]
          },
        ];
              
    constructor(public fb: FormBuilder){}          

    ngOnInit() {
       this.buildForms();
       this.detectChangesInForm();
    }
    
    alert(numberForm: number){
      if(numberForm==1){
        this.countriesInFilterForm1 = null;
        this.filter1Form.controls['selectedContinent1'].setValue(null);
        this.filter1Form.controls['selectedCountries1'].setValue(null);
      }
      else if(numberForm==2){
        this.countriesInFilterForm2 = null;
        this.filter2Form.controls['selectedContinent2'].setValue(null);
        this.filter2Form.controls['selectedCountries2'].setValue(null);
      }
      else{
        this.countriesInFilterForm3 = null;
        this.filter3Form.controls['selectedContinent3'].setValue(null);
        this.filter3Form.controls['selectedCountries3'].setValue(null);
      }
    }
    
    buildForms(){
      this.filter0Form = this.fb.group({
        typeOfNumberFilter: null,
        minimum: null,
        maximum: null
      });
      this.filter1Form = this.fb.group({
        selectedContinent1: null,
        selectedCountries1: null
      });
      this.filter2Form = this.fb.group({
        selectedContinent2: null,
        selectedCountries2: null
      });
      this.filter3Form = this.fb.group({
        selectedContinent3: null,
        selectedCountries3: null
      });
    }
    
    getCellValue(continents: any[], continent: any){
      for(let con of continents){
        if(con.name==continent.name){
          return con.country;
        }
      }
    }
    
    detectChangesInForm(){
      this.filter1Form.controls['selectedContinent1'].valueChanges.subscribe(
        value => {
          if(this.filter1Form.controls['selectedContinent1'].value!=null){
             this.countriesInFilterForm1 = this.filter1Form.get('selectedContinent1').value.countries.map((v)=>{return {label:v.name, value:v} });
             this.filter1Form.controls['selectedCountries1'].setValue(null);
          }
      });
       this.filter2Form.controls['selectedContinent2'].valueChanges.subscribe(
        value => {
          if(this.filter2Form.controls['selectedContinent2'].value!=null){
             this.countriesInFilterForm2 = this.filter2Form.get('selectedContinent2').value.countries.map((v)=>{return {label:v.name, value:v} });
             this.filter2Form.controls['selectedCountries2'].setValue(null);
          }
      });
       this.filter3Form.controls['selectedContinent3'].valueChanges.subscribe(
        value => {
          if(this.filter3Form.controls['selectedContinent3'].value!=null){
             this.countriesInFilterForm3 = this.filter3Form.get('selectedContinent3').value.countries.map((v)=>{return {label:v.name, value:v} });
             this.filter3Form.controls['selectedCountries3'].setValue(null);
          }
      });
    }
  
    getAdvanceType(){
      return this.filter0Form.controls['typeOfNumberFilter'].value;
    }
    
    getAdvanceMinimum(){
      return this.filter0Form.controls['minimum'].value;
    }
    
    getAdvanceMaximum(){
      return this.filter0Form.controls['maximum'].value;
    }
    
    
    getSelectedContinent1(){
      return this.filter1Form.controls['selectedContinent1'].value;
    }
    
    getSelectedCountries1(){
      return this.filter1Form.controls['selectedCountries1'].value;
    }
    
    getSelectedContinent2(){
      return this.filter2Form.controls['selectedContinent2'].value;
    }
    
    getSelectedCountries2(){
      return this.filter2Form.controls['selectedCountries2'].value;
    }
    
    
    getSelectedContinent3(){
      return this.filter3Form.controls['selectedContinent3'].value;
    }
    
    getSelectedCountries3(){
      return this.filter3Form.controls['selectedCountries3'].value;
    }
    
    
}
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';

import { AppComponent }   from './app.component';
import { AdvancePipe } from './advance.pipe';
import { CountryPipe } from './country.pipe';


// Import PrimeNG modules
import { DataTableModule,ListboxModule,  InputTextareaModule, InputSwitchModule, PanelModule, DropdownModule } from 'primeng';

@NgModule({
  imports:      [ ReactiveFormsModule, ListboxModule, BrowserModule, DataTableModule, InputSwitchModule, InputTextareaModule, FormsModule, PanelModule, DropdownModule ],
  declarations: [ AppComponent, AdvancePipe, CountryPipe],
  bootstrap:    [ AppComponent ],
})

export class AppModule { }

/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app.module';

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
body {
  padding: 2em;
  font-family: Arial, Helvetica, sans-serif;
}

.colordiv {
    margin: 1% 0 0 1%;
}

.colorbox {
    border-radius: 5px;
    width: 20px;
    height: 20px;
    display: inline-block;
    box-sizing: border-box;
    float: left;
    margin: 0 1% 1% 0;
    border: 1px solid black;
}

.fixed .ui-datatable-scrollable-view{
  float: none!important;
}

span, label, p, option, select, button{
  font-size: 11px !important;
}

.input-xs{
 width: 100% !important; 
}

p{
  margin-bottom: 0 !important;
}

.btn{
  margin-bottom: 10px !important;
}

input{
  margin-top: 5px !important;
}

.panel-heading{
  padding: 8px !important;
}

.panel-body{
  padding: 8px !important;
  height: 45vh;
}

.panel{
  margin: 2px !important;
}


.panels-filter{
  padding: 2px !important;
}
<!DOCTYPE html>
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- PrimeNG style dependencies -->
    <link rel="stylesheet" href="https://unpkg.com/primeng@2.0.1/resources/themes/omega/theme.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
    <link rel="stylesheet" href="https://unpkg.com/primeng@2.0.1/resources/primeng.min.css" />

    <!-- 1. Load libraries -->
    <!-- Polyfill for older browsers -->
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>

    <script src="https://unpkg.com/zone.js@0.6.25?main=browser"></script>
    <script src="https://unpkg.com/reflect-metadata@0.1.8"></script>
    <script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>

    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    
  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>
</html>


<!-- 
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->
/**
 * WEB ANGULAR VERSION
 * (based on systemjs.config.js in angular.io)
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },
    paths: {
      // paths serve as alias
      'npm:': 'https://unpkg.com/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ts':                        'npm:plugin-typescript@4.0.10/lib/plugin.js',
      'typescript':                'npm:typescript@2.0.3/lib/typescript.js',
      'primeng':                   'npm:primeng@2.0.1/primeng.js'

    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.ts',
        defaultExtension: 'ts'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      primeng: {
        defaultExtension: 'js'
      }
    }
  });

  if (!global.noBootstrap) { bootstrap(); }

  // Bootstrap the `AppModule`(skip the `app/main.ts` that normally does this)
  function bootstrap() {
    console.log('Auto-bootstrapping');

    // Stub out `app/main.ts` so System.import('app') doesn't fail if called in the index.html
    System.set(System.normalizeSync('app/main.ts'), System.newModule({ }));

    // bootstrap and launch the app (equivalent to standard main.ts)
    Promise.all([
      System.import('@angular/platform-browser-dynamic'),
      getAppModule()
    ])
    .then(function (imports) {
      var platform = imports[0];
      var app      = imports[1];
      platform.platformBrowserDynamic().bootstrapModule(app.AppModule);
    })
    .catch(function(err){ console.error(err); });
  }

  // Import AppModule or make the default AppModule if there isn't one
  // returns a promise for the AppModule
  function getAppModule() {
    if (global.noAppModule) {
      return makeAppModule();
    }
    return System.import('app/app.module').catch(makeAppModule)
  }

  function makeAppModule() {
    console.log('No AppModule; making a bare-bones, default AppModule');

    return Promise.all([
      System.import('@angular/core'),
      System.import('@angular/platform-browser'),
      System.import('app/app.component')
    ])
    .then(function (imports) {

      var core    = imports[0];
      var browser = imports[1];
      var appComp = imports[2].AppComponent;

      var AppModule = function() {}

      AppModule.annotations = [
        new core.NgModule({
          imports:      [ browser.BrowserModule ],
          declarations: [ appComp ],
          bootstrap:    [ appComp ]
        })
      ]
      return {AppModule: AppModule};
    })
  }
})(this);


  <p-dataTable [value]="persons | advance:  getAdvanceType():getAdvanceMinimum():getAdvanceMaximum() | country: getSelectedContinent1():getSelectedCountries1() | country: getSelectedContinent2():getSelectedCountries2() | country: getSelectedContinent3():getSelectedCountries3() | advance:  getAdvanceType():getAdvanceMinimum():getAdvanceMaximum()">
    <p-column field="firstName" header="First Name"></p-column>
    <p-column field="lastName" header="Last Name"></p-column>
    <p-column field="age" header="Age">
      <template let-col let-item="rowData" pTemplate="body">
          <span >{{item[col.field]}}</span>
      </template>
    </p-column>
    <p-column field="continents" *ngFor="let continent of continents">
      <template pTemplate="header">
         <span>{{continent.name}}</span>
      </template>
      <template let-col let-item="rowData" pTemplate="body">
          <span>{{getCellValue(item[col.field], continent)}}</span>
      </template>
    </p-column>
    <p-column field="height" header="Height"></p-column>
    <p-column field="salary" header="Salary"></p-column>
</p-dataTable>
 
<div class="row">
  <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 panelsFilter">
    <div class="panel panel-primary">
      <div class="panel-heading">Filter 0</div>
        <div class="panel-body panel-resizable">
          <form novalidate [formGroup]="filter0Form">
           <button class="btn btn-primary text-center btn-block btn-xs" (click)="alert(1)">Clear Filter</button>
           <div class="form-group">
             <p>Selected Continent</p>
             <select class="input-xs" formControlName="typeOfNumberFilter">
              <option [value]="'age'">Age</option>
              <option [value]="'height'">Height</option>
              <option [value]="'salary'">Salary</option>
             </select>
           </div>
           <div class="form-group">
             <span>Minimum<input type="number" class="input-xs" formControlName="minimum"></span>
             <span>Maximum<input type="number" class="input-xs" formControlName="maximum"></span>
            </div>
         </form>
      </div>
    </div>
  </div>
  <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 panelsFilter">
   <div class="panel panel-primary">
      <div class="panel-heading">Filter1 </div>
        <div class="panel-body panel-resizable">
          <form novalidate [formGroup]="filter1Form">
           <button class="btn btn-primary text-center btn-block btn-xs" (click)="alert(1)">Clear Filter</button>
           <div class="form-group">
             <p>Selected Continent</p>
             <select class="input-xs" formControlName="selectedContinent1">
              <option *ngFor="let continent of continents" [ngValue]="continent">{{continent.name}}</option>
             </select>
           </div>
           <div class="form-group">
             <p>Selected Countries</p>
             <p-listbox [options]="countriesInFilterForm1" formControlName="selectedCountries1" 
             multiple="multiple" 
             checkbox="checkbox" 
             [style]="{'margin-top':'10px','min-height':'15vh','width':'100%','max-height':'15vh'}"></p-listbox>
           </div>
         </form>
      </div>
    </div>
  </div>
  
 </div>
 
<p>{{getSelectedCountries1() | json}}</p>
 
 






# PrimeNG Issue Template
Please create a test case and attach the link of the plunkr to your github issue report.
import { Pipe, PipeTransForm }from '@angular/core';

@Pipe({
  name:'advance'
})

export class AdvancePipe implements PipeTransform {
  
  transform(persons: any , type : string, minimum : any, maximum: any) : any {
    if(type===undefined) {
      return persons;
    }
    else if(minimum==null && maximum==null){
      return persons;
    }
    else if(minimum==null && maximum!=null){
      if(type==='age'){
        return persons.filter(function(person){
          return person.age<=maximum;
        });
      }
      else if(type==='height'){
        return persons.filter(function(person){
           return person.height<=maximum;
        });
      }
      else{
        return persons.filter(function(person){
           return person.salary<=maximum;
        });
      }
    }
    else if(minimum!=null && maximum==null){
      if(type==='age'){
        return persons.filter(function(person){
          return person.age>=minimum;
        });
      }
      else if(type==='height'){
        return persons.filter(function(person){
           return person.height>=minimum;
        });
      }
      else{
        return persons.filter(function(person){
           return person.salary>=minimum;
        });
      }
    }
    else if(minimum!=null && maximum!=null){
      if(type==='age'){
        return persons.filter(function(person){
          return person.age>=minimum && person.age<=maximum;
        });
      }
      else if(type==='height'){
        return persons.filter(function(person){
           return person.height>=minimum && person.height<=maximum;
        });
      }
      else{
        return persons.filter(function(person){
           return person.salary>=minimum && person.salary<=maximum;
        });
      }
    }
    else{
      return persons;
    } 
  }
  
  
}
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'country'
})
export class CountryPipe implements PipeTransform {

  transform(persons: any, selectedContinent: any, selectedCountries: any []): any {
   if((selectedCountries==null || selectedCountries==[])){
      return persons;
   }
   else if((selectedCountries!=null || selectedCountries!=[])){
      return persons.filter(function(person){
          for(let continent of person.continents){
            if(continent.name==selectedContinent.name){
              for(let country of selectedCountries){
                if(country.name==continent.country){
                  return true;
                }
              }
              return false;
            }
          }
          return false;
      });
    }
    else{
      return persons;
    }
  }
  

}