Topic: MdbTableDirective Filter SearchLocalDataBy results specific columns
john.acb free asked 5 years ago
Angular PRO Member
Expected behavior
Currently implementing Mdbootstrap Datatable with search functionality
I've linked this to a local data source and can populate the table, no issue. Whoever, I noticed that the search (mdbTable.searchLocalDataBy) searches every column in the dataset even if not visible on the table (like Id or CreatedDate)
Actual behavior
Ability to provide columns of my dataset that should be filtered
Resources (screenshots, code snippets etc.)
https://mdbootstrap.com/docs/angular/tables/search/
this.mdbTable.searchLocalDataBy(this.searchText)
Bartosz Termena staff answered 5 years ago
Dear @john.acb
In the next version the new searchLocalDataByFields method will be added.
It will allow you to provide columns of your dataset that should be filtered.
Below is an example of how it will work:
this.mdbTable.searchLocalDataByFields(searchText, ['name', 'age'])
Best Regards, Bartosz
brandom247 free commented 5 years ago
Hi Bartosz, How can I search by multiple defined fields? I have this.mdbTable.searchLocalDataByFields(searchText, ['firstName', 'lastName']) Searching 'Steve Smith' returns no results. Searching 'Smith' returns many Smiths including Steve. Thanks!
Bartosz Termena staff commented 5 years ago
Dear @brandom247
It happens because searchLocalDataByFields
method allows you to search only on given fields, you can not search in two at once.
We don't have functionality to search in two field at once in our table search yet. We will definitely think about implementing this. I'll let you know when something goes well
Best Regards, Bartosz.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: 8.1.1
- Device: PC
- Browser: Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: Yes
Arkadiusz Idzikowski staff commented 5 years ago
We will take a closer look at this problem and add necessary changes.
john.acb free commented 5 years ago
Thank you @Arkadiusz Idzikowski. Please keep me posted on this.
I have another question regarding MdbTableDirective. The examples you have on your website show MdbTableDirective being mapped to a static list of data. Is it possible to have it linked to an observable to see real changes in real time? Let me know if I should create a separate ticket for that.
Thank you
Arkadiusz Idzikowski staff commented 5 years ago
Yes, you can use observable as well. We use *ngFor directives to render data from the array and it should update your table content automatically when the change in data array is detected. If you will encounter any problems with this approach please create separate ticket to let us know.
As for the problem with the search - we are still working on it and we will let you know here when this feature will be added to the library.
john.acb free commented 5 years ago
Thanks @Arkadiusz Idzikowski, I will open up another ticket for the Observable question. In regards to the Filtering question, how can I get notified for the 'fix'? Will it just be part of the next Angular release?
JB
Arkadiusz Idzikowski staff commented 5 years ago
Unfortunately we won't be able to add this fix to the nearest release. You can check our changelog to get information about the latest changes:
https://mdbootstrap.com/docs/angular/changelog
We will also update this thread to let you know when this fix will be available.