ODataV4Adaptor does not add $expand automaticly in the url


I use the DataManager with the ODataV4Adaptor to get data from an odata-service.
When I add a column which points to a nested property of the entity the adaptor does not automaticly add this to the $expand-part of the url, so the data for that column leaves blanc.

In EJ1 the adaptor adds this automaticly to the $expand-part of the url, but in EJ2 it doesn't.
Is this by design in EJ2?

mygrid.component.ts:

ngOnInit() {

    this.data = new DataManager({
      url: "https://server/odata/campaigns",
      crossDomain: true,
      adaptor: new OdataV4Adaptor()
    });

    this.columns = [
      { field: "id", headerText: "id", isPrimaryKey: true, width: 0, visible: false },
      { field: "code", headerText: "Code", width: 100 },
      { field: "name", headerText: "Name", width: 100 },
      { field: "createdOn", headerText: "Created On", width: 100, format: { type: 'datetime', format: "dd-MM-yyyy" } },
      { field: "createdBy.name", headerText: "Created By", width: 100 }
    ];

    this.grid.columns = this.columns;
    this.grid.dataSource = this.data;

}

1 Reply

DR Dhivya Rajendran Syncfusion Team July 13, 2018 12:26 PM UTC

Hi Sietse, 
Thanks for contacting Syncfusion support. 

We have validated your query and you can achieve your requirement by using the query property of Grid.  You can manipulate the expand query by adding the expand method to the query property, the solution might resolve your problem.  

Kindly refer to the below code example and documentation link for more information. 

<ejs-grid [dataSource]='data' [query]='query'> 
  <e-columns> 
    <e-column field='createdBy.name' headerText='Order ID' textAlign='Right' width=120></e-column> 
  . . . . . 
  </e-columns> 
</ejs-grid> 


export class AppComponent implements OnInit { 
 
  public data: DataManager; 
  public query: Query; 
 
  ngOnInit(): void { 
    this.data = new DataManager({ 
      url: 'http://server/odata/campaigns', 
      adaptor: new ODataV4Adaptor 
    }); 
    this.query = new Query().expand('createdBy'); 
  } 
} 


  
Regards,
R.Dhivya 


Loader.
Up arrow icon