akveo / akveo/ng2-smart-table

How can I receive returned values through a custom filter?

Ouverte
#1,357 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
TypeScript
Étoiles
1.6k
Forks
867
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

### How can I receive returned values through a custom filter and then call the Search function? I've tried for a long time without success.

```typescript
settings: any = {
actions: {
add: false,
edit: false,
delete: false,
},
pager: {
display: true,
perPage: 50,
},
columns: {
image: {
title: '編輯',
filter: false,
type: 'html',
width: '5%',
valuePrepareFunction: (cell, row) => {
return `

`;
}
},
Factory: {
title: '廠區',
type: 'html',
width: '15%',
filter: {
type: 'custom',
component: CustomSelectFilterComponent,
config: {
options: [],
response: (selectedValues: string[]) => {
console.log('selectedValues', selectedValues);
this.selectedFactory = selectedValues;
this.onSearch();
}
}
},
filterFunction(cell?: any, search?: string): boolean {
console.log('cell', cell);
console.log('search', search);
return this.doFilter(cell, search);
},
valuePrepareFunction: (data) => {
return `
${data}
`;
}
},
EmployeeNumber: {
title: '工號',
type: 'html',
width: '5%',
filter: {
type: 'text',
},
valuePrepareFunction: (data) => {
return `
${data}
`;
}
},
Name: {
title: '使用者名稱',
type: 'html',
width: '5%',
filter: {
type: 'text',
},
valuePrepareFunction: (data) => {
return `
${data}
`;
}
},
Username: {
title: '帳號',
type: 'html',
width: '5%',
filter: {
type: 'text',
},
valuePrepareFunction: (data) => {
return `
${data}
`;
}
},
Permission: {
title: '權限',
type: 'html',
width: '5%',
filter: {
type: 'custom',
component: CustomSelectFilterComponent,
config: {
options: [],
response: (selectedValues: string[]) => {
this.selectedPermission = selectedValues;
this.onSearch();
}
}
},
valuePrepareFunction: (data) => {
return `
${data}
`;
}
},
Group: {
title: '單位',
type: 'html',
width: '5%',
filter: {
type: 'custom',
component: CustomSelectFilterComponent,
config: {
options: [],
response: (selectedValues: string[]) => {
this.selectedGroup = selectedValues;
this.onSearch();
}
}
},
valuePrepareFunction: (data) => {
return `
${data}
`;
}
},
MailAddress: {
title: '信箱',
type: 'html',
width: '5%',
filter: {
type: 'text',
},
valuePrepareFunction: (data) => {
return `
${data}
`;
}
},
},
};

onSearch() {
const query = {
Factory: this.selectedFactory.length ? this.selectedFactory : null,
Permission: this.selectedPermission.length ? this.selectedPermission : null,
Group: this.selectedGroup.length ? this.selectedGroup : null,
};
this.service.Index({
Factory: query.Factory ? query.Factory.join(',') : Cookie.get('Factory'),
User: this.Base64Service.decodeValue(Cookie.get('Name')),
Permission: query.Permission ? query.Permission.join(',') : Cookie.get('Permission'),
Group: query.Group ? query.Group.join(',') : Cookie.get('Group'),
Auth_Person: this.Auth_Person,
Active: "0"
}).subscribe({
next: (data: PersonIndex[]) => {
this.source.load(data);
},
error: (error) => {
console.error('Error loading data', error.message);
}
});
}
![image](https://github.com/akveo/ng2-smart-table/assets/22144915/b6b79d58-a7f3-4350-a270-740602503e6f)

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.