Hi!
I have a grid where data are loaded with a service from a web api.
<kendo-grid [data]="logs" [pageSize]="state.take" [skip]="state.skip" [sort]="state.sort" [sortable]="{ allowUnsort: true, mode: 'multiple' }" [pageable]="true" [groupable]="true" [group]="state.group" [columnMenu]="false" [filterable]="'menu'" [filter]="state.filter" (filterChange)="filterChange($event)" [resizable]="true" (dataStateChange)="dataStateChange($event)"></kendo-grid>
This is the fetch method to query the data (logs):
public fetchLogs(state: DataSourceRequestState): Observable<any> { const queryStr = `${toDataSourceRequestString(state)}`; const hasGroups = state.group && state.group.length; return this.http // Send the state to the server .get(`${this.apiUrl}/log?${queryStr}`) .pipe( // Process the response map(({ data, total }: GridDataResult): GridDataResult => { const newData = hasGroups ? translateDataSourceResultGroups(data) : data; return { data: newData, total: total }; }), map(res => { res.data.map(item => { item.logZeit = new Date(item.logZeit); return item; }) return res; }) ); }
At the same time, the data are updated via signalR - like this:
logHubService.logCreated.subscribe(log => { log.logZeit = new Date(log.logZeit); this.logs.data = [log, ...this.logs.data]; this.logs.total += 1; }); logHubService.logUpdated.subscribe(log => { const logData = this.logs.data as ILog[]; let updateableLog = logData.filter(x => x.id === log.id); if (updateableLog.length == 1) { updateableLog[0].logLevel = log.logLevel; updateableLog[0].logLevelId = log.logLevelId; updateableLog[0].logTyp = log.logTyp; updateableLog[0].logTypId = log.logTypId; updateableLog[0].logZeit = new Date(log.logZeit); updateableLog[0].text = log.text; } }); logHubService.logDeleted.subscribe(log => { this.logs.data = this.logs.data.filter(x => x.id !== log.id); this.logs.total -= 1; });
But i have troubles when grid is filtered/grouped because the structure of this.logs.data has changed.
Can you give me a hint to solve this problem?
