BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
What is the correct way to filter records from data source in custom detail template?
Example below is from docs but it is using local data. I am using this but it does not filter - returns all records in source
import { Grid, DetailRow, DetailDataBoundEventArgs } from '@syncfusion/ej2-grids';
import { employeeData, data } from './datasource.ts';
Grid.Inject(DetailRow);
let grid: Grid = new Grid({
dataSource: employeeData.slice(2, 5),
detailTemplate: '#detailtemplate',
columns: [
{ field: 'FirstName', headerText: 'First Name', width: 140 },
{ field: 'LastName', headerText: 'Last Name', width: 140 },
{ field: 'Title', headerText: 'Title', width: 150 },
{ field: 'Country', headerText: 'Country', width: 150 }
],
detailDataBound: (e: DetailDataBoundEventArgs) => {
let detail = new Grid({
dataSource: data.filter((item: Object) => item['EmployeeID'] === e.data['EmployeeID']).slice(0, 3),
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 110 },
{ field: 'CustomerID', headerText: 'Customer Name', width: 140 },
{ field: 'ShipCountry', headerText: 'Ship Country', width: 150 }
]
});
detail.appendTo(<HTMLElement>e.detailElement.querySelector('.custom-grid'));
}
});
grid.appendTo('#Grid');
Hi Alex,
Greetings from Syncfusion support.
Based on your query, you want to get the filtered records from the datasource using ODataV4Adapator. We have discussed the same in detail in the below documentation. Refer the below documentation for more information.
Documentation: https://ej2.syncfusion.com/documentation/data/adaptors/#odatav4-adaptor
Regards,
Joseph I.