Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turbo Table global filter issue #4892

Closed
kcsahoo opened this issue Jan 19, 2018 · 6 comments
Closed

Turbo Table global filter issue #4892

kcsahoo opened this issue Jan 19, 2018 · 6 comments

Comments

@kcsahoo
Copy link

kcsahoo commented Jan 19, 2018

The global filter throws error on input.
Throws length of undefined error in line 575 in the component js file.
My table template is:
<p-table #dt [value]="rows" reorderableColumns="true" scrollable="true" scrollHeight="700px">


<input type="text" pInputText size="70" placeholder="{{'companies.management.Search' | translate}}" (input)="dt.filterGlobal($event.target.value, 'contains')" style="width:auto">
<button pButton type="button" *ngIf="canManageCompanies" class="ui-button-secondary" (click)="newCompany(company)" icon="fa-plus-square-o" label=" {{'companies.management.NewCompany' | translate}}" style="float:right">




{{'companies.management.Name' | translate}}
{{'companies.management.Users' | translate}}





<tr [pSelectableRow]="company">
{{company.id}}
{{company.name}}
{{company.applicationUsers}}
<button type="button" pButton (click)="editCompany(company)" class="ui-button-secondary" icon="fa-pencil-square-o" label="{{'companies.management.Edit' | translate}}">
<button type="button" pButton (click)="deleteCompany(company)" class="ui-button-secondary" icon="fa-trash-o" label="{{'companies.management.Delete' | translate}}">



(Count: {{rowCount}})

@mehmet2006
Copy link

mehmet2006 commented Jan 19, 2018

I am getting same problem.
I am using firebase firestore to get data.
I fill the table without any problem.
But global filter throws error:

ERROR TypeError: Cannot read property 'length' of undefined at Table._filter (table.js:575) at Table.filter (table.js:540) at Table.filterGlobal (table.js:550) at Object.eval [as handleEvent] (UsersComponent.html:11) at handleEvent (core.js:13540) at callWithDebugContext (core.js:15049) at Object.debugHandleEvent [as handleEvent] (core.js:14636) at dispatchEvent (core.js:9955) at eval (core.js:10580) at HTMLInputElement.eval (platform-browser.js:2628)

Edit:
Btw. I am creating table manually. I define columns manually.

@bias-keenly
Copy link
Contributor

bias-keenly commented Jan 19, 2018

It is confusing, was having the same issue. You need to define the column dictionary and assign to [columns] on the p-table like the example. The global filter uses this.columns to figure out the columns to filter on. Without that defined will get that error.

@mehmet2006
Copy link

mehmet2006 commented Jan 19, 2018

@bias-keenly you are right. I've just created table dynamically and it works. both global and normal filtering works when table is created dynamically.

When I tried to add cols to the manually created table, it didn't throw the previous error but filtering didnt work right...

@pantonis
Copy link
Contributor

pantonis commented Jan 21, 2018

Maybe related to this #4885

For a temp workaround I set [lazy]="false"

@cagataycivici
Copy link
Member

cagataycivici commented Jan 21, 2018

Tracked at #4908

@togbyte
Copy link

togbyte commented Jan 22, 2018

I ran into a similar issue, but resolve it by setting appropriate field and add to template body.

Global filtering works if you set [columns]="cols" where
this.cols=[ {field: "col1-field", header:"col1-header"}]

Only col1-field is searchable. You need to specify "columns" in your pTemplate="body". For example,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants