我需要在DataSourceRequestState中添加一个默认过滤器,以便数据库请求自动包含一些初始过滤器值。我正在尝试通过this.applicationName进行过滤。有谁知道如何在网格中添加预过滤器?
public getApplicationServers(state: DataSourceRequestState): Observable<DataResult> {
const queryStr = `${toDataSourceRequestString(state)}`; // Serialize the state
const hasGroups = state.group && state.group.length;
return this.http
.get(`${'api/BircCertificationForm'}?${queryStr}`) // Send the state to the server
.map(response => response.json())
.map(({ Data, Total, AggregateResults }) => // Process the response
(<GridDataResult>{
// If there are groups, convert them to a compatible format
data: hasGroups ? translateDataSourceResultGroups(Data) : Data,
total: Total,
// Convert the aggregates if such exist
//aggregateResult: translateAggregateResults(aggregateResults)
})
)
}
以下是此组件正在调用的DataService代码。
<embed id="plugin" type="application/x-google-chrome-pdf" src="http:xxx/DocumentInquiry.aspx?DocumentNo=12502" stream-url="blob:chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/1c86700d-0230-43b1-8b5e-eb219a2220af" headers="Content-Type: application/pdf
Content-Length: 50080
Cache-Control: private
Server: Microsoft-IIS/7.5
Content-Disposition: inline;filename=DocumentInquiry.pdf
X-Powered-By: ASP.NET
答案 0 :(得分:1)
您可以绑定Grid组件的filter input并提供初始过滤器描述符,如下面的演示:
<kendo-grid
[data]="gridData"
[pageSize]="state.take"
[skip]="state.skip"
[sort]="state.sort"
[filter]="state.filter"
[sortable]="true"
[pageable]="true"
[filterable]="true"
(dataStateChange)="dataStateChange($event)"
>
...
export class AppComponent {
private state: State = {
skip: 0,
take: 5,
// Initial filter descriptor
filter: {
logic: "and",
filters: [{ field: "ProductName", operator: "contains", value: "Chef" }]
}
};
过滤器只需要有“逻辑”和“过滤器”字段,而不是 filterBy()函数调用的结果。