Implementing NGX Datatable filtering on all columns












8















I've been trying to get this working with no luck. I've been referencing these resources for help:
http://swimlane.github.io/ngx-datatable/#filter
https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts



Basically i just want to allow my filter to apply to more than a single column, without implementing code to handle every column. (Some datatables have 20+ columns!)



Example Code:



//HTML
<input type='text' placeholder='Filter' (keyup)='updateFilter($event.target.value)' />

<ngx-datatable
class="material"
columnMode="force"
[columns]="gridProperties.FilteredColumns"
[footerHeight]="50"
[loadingIndicator]="gridLoadingIndicator"
[rows]="filteredList"
[scrollbarH]="false"
[scrollbarV]="true"
[selected]="selectedItem"
[selectionType]="'single'"
style="min-height:400px;">
</ngx-datatable>

//TYPESCRIPT
public items: Item;

updateFilter(filterValue) {
const lowerValue = filterValue.toLowerCase();

this.filteredList = this.items.filter(item => item.name.toLowerCase().indexOf(lowerValue) !== -1 || !lowerValue);
}


Here I am obviously just handling filtering for the 'name' property of my items array. This works great as is, but like I had mentioned, if the grid contains many columns I'd like one method to handle all of them. Any help or tips are appreciated.










share|improve this question

























  • That would be a great feature :))

    – Philip Enc
    Dec 10 '17 at 0:30











  • did you find a solution for this?

    – mike_t
    Jan 21 '18 at 19:04











  • check this link I found this solution stackoverflow.com/questions/48299331/…

    – ashokbalaga
    Jan 21 at 9:01
















8















I've been trying to get this working with no luck. I've been referencing these resources for help:
http://swimlane.github.io/ngx-datatable/#filter
https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts



Basically i just want to allow my filter to apply to more than a single column, without implementing code to handle every column. (Some datatables have 20+ columns!)



Example Code:



//HTML
<input type='text' placeholder='Filter' (keyup)='updateFilter($event.target.value)' />

<ngx-datatable
class="material"
columnMode="force"
[columns]="gridProperties.FilteredColumns"
[footerHeight]="50"
[loadingIndicator]="gridLoadingIndicator"
[rows]="filteredList"
[scrollbarH]="false"
[scrollbarV]="true"
[selected]="selectedItem"
[selectionType]="'single'"
style="min-height:400px;">
</ngx-datatable>

//TYPESCRIPT
public items: Item;

updateFilter(filterValue) {
const lowerValue = filterValue.toLowerCase();

this.filteredList = this.items.filter(item => item.name.toLowerCase().indexOf(lowerValue) !== -1 || !lowerValue);
}


Here I am obviously just handling filtering for the 'name' property of my items array. This works great as is, but like I had mentioned, if the grid contains many columns I'd like one method to handle all of them. Any help or tips are appreciated.










share|improve this question

























  • That would be a great feature :))

    – Philip Enc
    Dec 10 '17 at 0:30











  • did you find a solution for this?

    – mike_t
    Jan 21 '18 at 19:04











  • check this link I found this solution stackoverflow.com/questions/48299331/…

    – ashokbalaga
    Jan 21 at 9:01














8












8








8


5






I've been trying to get this working with no luck. I've been referencing these resources for help:
http://swimlane.github.io/ngx-datatable/#filter
https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts



Basically i just want to allow my filter to apply to more than a single column, without implementing code to handle every column. (Some datatables have 20+ columns!)



Example Code:



//HTML
<input type='text' placeholder='Filter' (keyup)='updateFilter($event.target.value)' />

<ngx-datatable
class="material"
columnMode="force"
[columns]="gridProperties.FilteredColumns"
[footerHeight]="50"
[loadingIndicator]="gridLoadingIndicator"
[rows]="filteredList"
[scrollbarH]="false"
[scrollbarV]="true"
[selected]="selectedItem"
[selectionType]="'single'"
style="min-height:400px;">
</ngx-datatable>

//TYPESCRIPT
public items: Item;

updateFilter(filterValue) {
const lowerValue = filterValue.toLowerCase();

this.filteredList = this.items.filter(item => item.name.toLowerCase().indexOf(lowerValue) !== -1 || !lowerValue);
}


Here I am obviously just handling filtering for the 'name' property of my items array. This works great as is, but like I had mentioned, if the grid contains many columns I'd like one method to handle all of them. Any help or tips are appreciated.










share|improve this question
















I've been trying to get this working with no luck. I've been referencing these resources for help:
http://swimlane.github.io/ngx-datatable/#filter
https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts



Basically i just want to allow my filter to apply to more than a single column, without implementing code to handle every column. (Some datatables have 20+ columns!)



Example Code:



//HTML
<input type='text' placeholder='Filter' (keyup)='updateFilter($event.target.value)' />

<ngx-datatable
class="material"
columnMode="force"
[columns]="gridProperties.FilteredColumns"
[footerHeight]="50"
[loadingIndicator]="gridLoadingIndicator"
[rows]="filteredList"
[scrollbarH]="false"
[scrollbarV]="true"
[selected]="selectedItem"
[selectionType]="'single'"
style="min-height:400px;">
</ngx-datatable>

//TYPESCRIPT
public items: Item;

updateFilter(filterValue) {
const lowerValue = filterValue.toLowerCase();

this.filteredList = this.items.filter(item => item.name.toLowerCase().indexOf(lowerValue) !== -1 || !lowerValue);
}


Here I am obviously just handling filtering for the 'name' property of my items array. This works great as is, but like I had mentioned, if the grid contains many columns I'd like one method to handle all of them. Any help or tips are appreciated.







angular typescript ngx-datatable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 11:30









David Victor

710724




710724










asked Jul 14 '17 at 15:06









BlankdudBlankdud

3381616




3381616













  • That would be a great feature :))

    – Philip Enc
    Dec 10 '17 at 0:30











  • did you find a solution for this?

    – mike_t
    Jan 21 '18 at 19:04











  • check this link I found this solution stackoverflow.com/questions/48299331/…

    – ashokbalaga
    Jan 21 at 9:01



















  • That would be a great feature :))

    – Philip Enc
    Dec 10 '17 at 0:30











  • did you find a solution for this?

    – mike_t
    Jan 21 '18 at 19:04











  • check this link I found this solution stackoverflow.com/questions/48299331/…

    – ashokbalaga
    Jan 21 at 9:01

















That would be a great feature :))

– Philip Enc
Dec 10 '17 at 0:30





That would be a great feature :))

– Philip Enc
Dec 10 '17 at 0:30













did you find a solution for this?

– mike_t
Jan 21 '18 at 19:04





did you find a solution for this?

– mike_t
Jan 21 '18 at 19:04













check this link I found this solution stackoverflow.com/questions/48299331/…

– ashokbalaga
Jan 21 at 9:01





check this link I found this solution stackoverflow.com/questions/48299331/…

– ashokbalaga
Jan 21 at 9:01












3 Answers
3






active

oldest

votes


















6














Using the example TS file for filtering
(https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts)
as a foundation, I was able to successfully make it filter all columns dynamically (it will filter all columns without the need to specify them). I've included what I believe to be all the necessary parts for this to work but also trimmed the code down as much as I could to make it easier to understand.



HTML



<ngx-datatable
#table
class="material striped scroll-vertical"
[rows]="data"
[columns]="cols"
[columnMode]="'force'"
[headerHeight]="35"
[footerHeight]="35"
[rowHeight]="'auto'"
[limit]="pageSize"
[selectionType]="'single'">

<input type="text" (keyup)='filterDatatable($event)'>


TYPESCRIPT



cols = [{name:'First Name'},{name:'Last Name'},{name:'Address'}];
data = ;
filteredData = ;

// dummy data for datatable rows
dummyData = [
{firstName:'Daenarys',lastName:'Targaryen',address:'Dragonstone'},
{firstName:'Sansa',lastName:'Stark',address:'Winterfell'},
{firstName:'Cersei',lastName:'Lannister',address:'Kings Landing'},
{firstName:'Brienne',lastName:'Tarth',address:'Sapphire Island'},
{firstName:'Lyanna',lastName:'Mormont',address:'Bear Island'},
{firstName:'Margaery',lastName:'Tyrell',address:'Highgarden'}
]

ngOnInit(){
// populate datatable rows
this.data = this.dummyData;
// copy over dataset to empty object
this.filteredData = this.dummyData;
}

// filters results
filterDatatable(event){
// get the value of the key pressed and make it lowercase
let val = event.target.value.toLowerCase();
// get the amount of columns in the table
let colsAmt = this.cols.length;
// get the key names of each column in the dataset
let keys = Object.keys(this.dummyData[0]);
// assign filtered matches to the active datatable
this.data = this.filteredData.filter(function(item){
// iterate through each row's column data
for (let i=0; i<colsAmt; i++){
// check for a match
if (item[keys[i]].toString().toLowerCase().indexOf(val) !== -1 || !val){
// found match, return true to add to result set
return true;
}
}
});
// whenever the filter changes, always go back to the first page
this.table.offset = 0;
}





share|improve this answer

































    1














    here is an example of your code with multiple columns filtering:



    updateFilter(filter: string): void {

    const val = filter.trim().toLowerCase();

    this.filteredList = this.items.slice().filter((item: any) => {
    let searchStr = '';
    for (let i = 0; i < this.gridProperties.FilteredColumns.length; i++) {
    searchStr += (item[this.gridProperties.FilteredColumns[i]]).toString().toLowerCase();
    }
    return searchStr.indexOf(val) !== -1 || !val;
    });
    }


    If I did not made any errors, it should work correctly.






    share|improve this answer































      0














      **100 % working for anyone**
      **Before doing import the**

      import { DatatableComponent } from '@swimlane/ngx-datatable';
      ViewChild(DatatableComponent) table: DatatableComponent;

      // Typescript
      updateFilter(event) {
      const val = event.target.value.toLowerCase();
      var returnData: any;
      // filter our data
      const temp = this.temp.filter(function (d) {

      if (d.yourFirstColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
      returnData = d.user_name.toLowerCase().indexOf(val) !== -1 || !val;
      } else if (d.yourSecondColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
      returnData = d.notes_title.toLowerCase().indexOf(val) !== -1 || !val;

      }
      return returnData;
      });

      // HTML

      <input placeholder="Search Order" (keyup)='updateFilter($event)'>





      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45106241%2fimplementing-ngx-datatable-filtering-on-all-columns%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        6














        Using the example TS file for filtering
        (https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts)
        as a foundation, I was able to successfully make it filter all columns dynamically (it will filter all columns without the need to specify them). I've included what I believe to be all the necessary parts for this to work but also trimmed the code down as much as I could to make it easier to understand.



        HTML



        <ngx-datatable
        #table
        class="material striped scroll-vertical"
        [rows]="data"
        [columns]="cols"
        [columnMode]="'force'"
        [headerHeight]="35"
        [footerHeight]="35"
        [rowHeight]="'auto'"
        [limit]="pageSize"
        [selectionType]="'single'">

        <input type="text" (keyup)='filterDatatable($event)'>


        TYPESCRIPT



        cols = [{name:'First Name'},{name:'Last Name'},{name:'Address'}];
        data = ;
        filteredData = ;

        // dummy data for datatable rows
        dummyData = [
        {firstName:'Daenarys',lastName:'Targaryen',address:'Dragonstone'},
        {firstName:'Sansa',lastName:'Stark',address:'Winterfell'},
        {firstName:'Cersei',lastName:'Lannister',address:'Kings Landing'},
        {firstName:'Brienne',lastName:'Tarth',address:'Sapphire Island'},
        {firstName:'Lyanna',lastName:'Mormont',address:'Bear Island'},
        {firstName:'Margaery',lastName:'Tyrell',address:'Highgarden'}
        ]

        ngOnInit(){
        // populate datatable rows
        this.data = this.dummyData;
        // copy over dataset to empty object
        this.filteredData = this.dummyData;
        }

        // filters results
        filterDatatable(event){
        // get the value of the key pressed and make it lowercase
        let val = event.target.value.toLowerCase();
        // get the amount of columns in the table
        let colsAmt = this.cols.length;
        // get the key names of each column in the dataset
        let keys = Object.keys(this.dummyData[0]);
        // assign filtered matches to the active datatable
        this.data = this.filteredData.filter(function(item){
        // iterate through each row's column data
        for (let i=0; i<colsAmt; i++){
        // check for a match
        if (item[keys[i]].toString().toLowerCase().indexOf(val) !== -1 || !val){
        // found match, return true to add to result set
        return true;
        }
        }
        });
        // whenever the filter changes, always go back to the first page
        this.table.offset = 0;
        }





        share|improve this answer






























          6














          Using the example TS file for filtering
          (https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts)
          as a foundation, I was able to successfully make it filter all columns dynamically (it will filter all columns without the need to specify them). I've included what I believe to be all the necessary parts for this to work but also trimmed the code down as much as I could to make it easier to understand.



          HTML



          <ngx-datatable
          #table
          class="material striped scroll-vertical"
          [rows]="data"
          [columns]="cols"
          [columnMode]="'force'"
          [headerHeight]="35"
          [footerHeight]="35"
          [rowHeight]="'auto'"
          [limit]="pageSize"
          [selectionType]="'single'">

          <input type="text" (keyup)='filterDatatable($event)'>


          TYPESCRIPT



          cols = [{name:'First Name'},{name:'Last Name'},{name:'Address'}];
          data = ;
          filteredData = ;

          // dummy data for datatable rows
          dummyData = [
          {firstName:'Daenarys',lastName:'Targaryen',address:'Dragonstone'},
          {firstName:'Sansa',lastName:'Stark',address:'Winterfell'},
          {firstName:'Cersei',lastName:'Lannister',address:'Kings Landing'},
          {firstName:'Brienne',lastName:'Tarth',address:'Sapphire Island'},
          {firstName:'Lyanna',lastName:'Mormont',address:'Bear Island'},
          {firstName:'Margaery',lastName:'Tyrell',address:'Highgarden'}
          ]

          ngOnInit(){
          // populate datatable rows
          this.data = this.dummyData;
          // copy over dataset to empty object
          this.filteredData = this.dummyData;
          }

          // filters results
          filterDatatable(event){
          // get the value of the key pressed and make it lowercase
          let val = event.target.value.toLowerCase();
          // get the amount of columns in the table
          let colsAmt = this.cols.length;
          // get the key names of each column in the dataset
          let keys = Object.keys(this.dummyData[0]);
          // assign filtered matches to the active datatable
          this.data = this.filteredData.filter(function(item){
          // iterate through each row's column data
          for (let i=0; i<colsAmt; i++){
          // check for a match
          if (item[keys[i]].toString().toLowerCase().indexOf(val) !== -1 || !val){
          // found match, return true to add to result set
          return true;
          }
          }
          });
          // whenever the filter changes, always go back to the first page
          this.table.offset = 0;
          }





          share|improve this answer




























            6












            6








            6







            Using the example TS file for filtering
            (https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts)
            as a foundation, I was able to successfully make it filter all columns dynamically (it will filter all columns without the need to specify them). I've included what I believe to be all the necessary parts for this to work but also trimmed the code down as much as I could to make it easier to understand.



            HTML



            <ngx-datatable
            #table
            class="material striped scroll-vertical"
            [rows]="data"
            [columns]="cols"
            [columnMode]="'force'"
            [headerHeight]="35"
            [footerHeight]="35"
            [rowHeight]="'auto'"
            [limit]="pageSize"
            [selectionType]="'single'">

            <input type="text" (keyup)='filterDatatable($event)'>


            TYPESCRIPT



            cols = [{name:'First Name'},{name:'Last Name'},{name:'Address'}];
            data = ;
            filteredData = ;

            // dummy data for datatable rows
            dummyData = [
            {firstName:'Daenarys',lastName:'Targaryen',address:'Dragonstone'},
            {firstName:'Sansa',lastName:'Stark',address:'Winterfell'},
            {firstName:'Cersei',lastName:'Lannister',address:'Kings Landing'},
            {firstName:'Brienne',lastName:'Tarth',address:'Sapphire Island'},
            {firstName:'Lyanna',lastName:'Mormont',address:'Bear Island'},
            {firstName:'Margaery',lastName:'Tyrell',address:'Highgarden'}
            ]

            ngOnInit(){
            // populate datatable rows
            this.data = this.dummyData;
            // copy over dataset to empty object
            this.filteredData = this.dummyData;
            }

            // filters results
            filterDatatable(event){
            // get the value of the key pressed and make it lowercase
            let val = event.target.value.toLowerCase();
            // get the amount of columns in the table
            let colsAmt = this.cols.length;
            // get the key names of each column in the dataset
            let keys = Object.keys(this.dummyData[0]);
            // assign filtered matches to the active datatable
            this.data = this.filteredData.filter(function(item){
            // iterate through each row's column data
            for (let i=0; i<colsAmt; i++){
            // check for a match
            if (item[keys[i]].toString().toLowerCase().indexOf(val) !== -1 || !val){
            // found match, return true to add to result set
            return true;
            }
            }
            });
            // whenever the filter changes, always go back to the first page
            this.table.offset = 0;
            }





            share|improve this answer















            Using the example TS file for filtering
            (https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts)
            as a foundation, I was able to successfully make it filter all columns dynamically (it will filter all columns without the need to specify them). I've included what I believe to be all the necessary parts for this to work but also trimmed the code down as much as I could to make it easier to understand.



            HTML



            <ngx-datatable
            #table
            class="material striped scroll-vertical"
            [rows]="data"
            [columns]="cols"
            [columnMode]="'force'"
            [headerHeight]="35"
            [footerHeight]="35"
            [rowHeight]="'auto'"
            [limit]="pageSize"
            [selectionType]="'single'">

            <input type="text" (keyup)='filterDatatable($event)'>


            TYPESCRIPT



            cols = [{name:'First Name'},{name:'Last Name'},{name:'Address'}];
            data = ;
            filteredData = ;

            // dummy data for datatable rows
            dummyData = [
            {firstName:'Daenarys',lastName:'Targaryen',address:'Dragonstone'},
            {firstName:'Sansa',lastName:'Stark',address:'Winterfell'},
            {firstName:'Cersei',lastName:'Lannister',address:'Kings Landing'},
            {firstName:'Brienne',lastName:'Tarth',address:'Sapphire Island'},
            {firstName:'Lyanna',lastName:'Mormont',address:'Bear Island'},
            {firstName:'Margaery',lastName:'Tyrell',address:'Highgarden'}
            ]

            ngOnInit(){
            // populate datatable rows
            this.data = this.dummyData;
            // copy over dataset to empty object
            this.filteredData = this.dummyData;
            }

            // filters results
            filterDatatable(event){
            // get the value of the key pressed and make it lowercase
            let val = event.target.value.toLowerCase();
            // get the amount of columns in the table
            let colsAmt = this.cols.length;
            // get the key names of each column in the dataset
            let keys = Object.keys(this.dummyData[0]);
            // assign filtered matches to the active datatable
            this.data = this.filteredData.filter(function(item){
            // iterate through each row's column data
            for (let i=0; i<colsAmt; i++){
            // check for a match
            if (item[keys[i]].toString().toLowerCase().indexOf(val) !== -1 || !val){
            // found match, return true to add to result set
            return true;
            }
            }
            });
            // whenever the filter changes, always go back to the first page
            this.table.offset = 0;
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 15 '18 at 13:10









            Senthil

            12611




            12611










            answered Jan 24 '18 at 23:15









            Cole PacianoCole Paciano

            6114




            6114

























                1














                here is an example of your code with multiple columns filtering:



                updateFilter(filter: string): void {

                const val = filter.trim().toLowerCase();

                this.filteredList = this.items.slice().filter((item: any) => {
                let searchStr = '';
                for (let i = 0; i < this.gridProperties.FilteredColumns.length; i++) {
                searchStr += (item[this.gridProperties.FilteredColumns[i]]).toString().toLowerCase();
                }
                return searchStr.indexOf(val) !== -1 || !val;
                });
                }


                If I did not made any errors, it should work correctly.






                share|improve this answer




























                  1














                  here is an example of your code with multiple columns filtering:



                  updateFilter(filter: string): void {

                  const val = filter.trim().toLowerCase();

                  this.filteredList = this.items.slice().filter((item: any) => {
                  let searchStr = '';
                  for (let i = 0; i < this.gridProperties.FilteredColumns.length; i++) {
                  searchStr += (item[this.gridProperties.FilteredColumns[i]]).toString().toLowerCase();
                  }
                  return searchStr.indexOf(val) !== -1 || !val;
                  });
                  }


                  If I did not made any errors, it should work correctly.






                  share|improve this answer


























                    1












                    1








                    1







                    here is an example of your code with multiple columns filtering:



                    updateFilter(filter: string): void {

                    const val = filter.trim().toLowerCase();

                    this.filteredList = this.items.slice().filter((item: any) => {
                    let searchStr = '';
                    for (let i = 0; i < this.gridProperties.FilteredColumns.length; i++) {
                    searchStr += (item[this.gridProperties.FilteredColumns[i]]).toString().toLowerCase();
                    }
                    return searchStr.indexOf(val) !== -1 || !val;
                    });
                    }


                    If I did not made any errors, it should work correctly.






                    share|improve this answer













                    here is an example of your code with multiple columns filtering:



                    updateFilter(filter: string): void {

                    const val = filter.trim().toLowerCase();

                    this.filteredList = this.items.slice().filter((item: any) => {
                    let searchStr = '';
                    for (let i = 0; i < this.gridProperties.FilteredColumns.length; i++) {
                    searchStr += (item[this.gridProperties.FilteredColumns[i]]).toString().toLowerCase();
                    }
                    return searchStr.indexOf(val) !== -1 || !val;
                    });
                    }


                    If I did not made any errors, it should work correctly.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 23 '18 at 15:04









                    JosuJosu

                    111




                    111























                        0














                        **100 % working for anyone**
                        **Before doing import the**

                        import { DatatableComponent } from '@swimlane/ngx-datatable';
                        ViewChild(DatatableComponent) table: DatatableComponent;

                        // Typescript
                        updateFilter(event) {
                        const val = event.target.value.toLowerCase();
                        var returnData: any;
                        // filter our data
                        const temp = this.temp.filter(function (d) {

                        if (d.yourFirstColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                        returnData = d.user_name.toLowerCase().indexOf(val) !== -1 || !val;
                        } else if (d.yourSecondColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                        returnData = d.notes_title.toLowerCase().indexOf(val) !== -1 || !val;

                        }
                        return returnData;
                        });

                        // HTML

                        <input placeholder="Search Order" (keyup)='updateFilter($event)'>





                        share|improve this answer




























                          0














                          **100 % working for anyone**
                          **Before doing import the**

                          import { DatatableComponent } from '@swimlane/ngx-datatable';
                          ViewChild(DatatableComponent) table: DatatableComponent;

                          // Typescript
                          updateFilter(event) {
                          const val = event.target.value.toLowerCase();
                          var returnData: any;
                          // filter our data
                          const temp = this.temp.filter(function (d) {

                          if (d.yourFirstColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                          returnData = d.user_name.toLowerCase().indexOf(val) !== -1 || !val;
                          } else if (d.yourSecondColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                          returnData = d.notes_title.toLowerCase().indexOf(val) !== -1 || !val;

                          }
                          return returnData;
                          });

                          // HTML

                          <input placeholder="Search Order" (keyup)='updateFilter($event)'>





                          share|improve this answer


























                            0












                            0








                            0







                            **100 % working for anyone**
                            **Before doing import the**

                            import { DatatableComponent } from '@swimlane/ngx-datatable';
                            ViewChild(DatatableComponent) table: DatatableComponent;

                            // Typescript
                            updateFilter(event) {
                            const val = event.target.value.toLowerCase();
                            var returnData: any;
                            // filter our data
                            const temp = this.temp.filter(function (d) {

                            if (d.yourFirstColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                            returnData = d.user_name.toLowerCase().indexOf(val) !== -1 || !val;
                            } else if (d.yourSecondColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                            returnData = d.notes_title.toLowerCase().indexOf(val) !== -1 || !val;

                            }
                            return returnData;
                            });

                            // HTML

                            <input placeholder="Search Order" (keyup)='updateFilter($event)'>





                            share|improve this answer













                            **100 % working for anyone**
                            **Before doing import the**

                            import { DatatableComponent } from '@swimlane/ngx-datatable';
                            ViewChild(DatatableComponent) table: DatatableComponent;

                            // Typescript
                            updateFilter(event) {
                            const val = event.target.value.toLowerCase();
                            var returnData: any;
                            // filter our data
                            const temp = this.temp.filter(function (d) {

                            if (d.yourFirstColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                            returnData = d.user_name.toLowerCase().indexOf(val) !== -1 || !val;
                            } else if (d.yourSecondColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
                            returnData = d.notes_title.toLowerCase().indexOf(val) !== -1 || !val;

                            }
                            return returnData;
                            });

                            // HTML

                            <input placeholder="Search Order" (keyup)='updateFilter($event)'>






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Oct 18 '18 at 11:14









                            Sachin from PuneSachin from Pune

                            181211




                            181211






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45106241%2fimplementing-ngx-datatable-filtering-on-all-columns%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Florida Star v. B. J. F.

                                Danny Elfman

                                Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues