I am working on an AngularJS app that includes the following UI grid:
this.resultGrid = {
enableRowSelection: true,
enableRowHeaderSelection: false,
enableHorizontalScrollbar: 0,
enableSorting: true,
columnDefs: [
{ name: 'Id', field: 'id' },
{ name: 'Name', field: 'name' },
{ name: 'Street', field: 'street' },
{ name: 'Postcode', field: 'postcode' },
{ name: 'City', field: 'city' },
{ name: 'Country', field: 'country' },
{ name: 'In System', field: 'inSys()' }
],
data: [{ city: "Warsaw", country: "Poland", id: "123456789", name: "Company 1", postcode: "00-122", street: "Waszyngtona", inSys: this.inSys(id); }, //compilation error - cannot find name "id"
{ city: "London", country: "UK", id: "987654321", name: "Company 2", street: "Downtown" }]
};
Furthermore, I have a function that I need to call within this controller:
inSys = (id: string) => {
if (id== null || id.length == 0)
return false;
return this.myService.recordExistsInSys(id);
}
I have been unable to find any examples of how to pass a function as a ui-grid
column value in TypeScript. Do you have any ideas on how to handle this?