We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

$expand nested properties

I'm able to $expand multiple levels of nested properties as follows:

        this.query = new Query().expand('Product($expand=Customer)');

While this works, it is awkward to manipulate the odata uri this way and I don't know if it's supported.  Is there a better way to do this?  Traditional dot-style property notation in <e-column> doesn't seem to make the DataManager add the $expand option to the uri.

Thanks!

-k

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team October 1, 2019 08:50 AM UTC

Hi Kelly, 

Thanks for contacting us. 

You can manipulate the expand Query using “query” property of Grid as like the below way. Please refer the code example and sample from the link below, 

App.component.html 
<div class="control-section"> 
    <ejs-grid #grid [dataSource]='data' [query]="query" [pageSettings]='pageSettings'> 
            <e-columns> 
            <e-column field='UserName' headerText='Customer ID' width='160'></e-column> 
            <e-column field='FirstName' width='120' textAlign='Right'></e-column> 
            <e-column field='LastName' width='150' ></e-column> 
        </e-columns> 
    </ejs-grid> 
 
</div> 

App.component.ts 
const SERVICE_URI: string = 'https://services.odata.org/V4/(S(0j5uiuuhvaybfuc2llcclf3g))/TripPinServiceRW/People'; 
 
@Component({ 
    selector: 'app-root', 
    templateUrl: 'app.component.html' 
}) 
export class AppComponent { 
    public data: DataManager;  
    public pageSettings: Object;  
public query:any 
    @ViewChild('grid',{static: true}) 
    public grid: GridComponent; 
 
    ngOnInit(): void { 
        this.data= new DataManager({ url: SERVICE_URI, adaptor: new ODataV4Adaptor }) 
        this.query = new Query().expand('Trips'); 
    } 
} 



Screenshot:  
 

Please get backto us, if you need further assistance. 

Regards, 
Thavasianand S. 



KH Kelly Harrison October 1, 2019 12:22 PM UTC

That's exactly what I'm doing.  However, that doesn't answer the question of nested properties with multiple levels.  In my case, it's something like this:

ProductInventory -> Product -> Customer

In the grid displaying ProductInventory data, I want to show the Customer name.  Using .expand('Product.Customer') doesn't work while my method does.  However that doesn't seem to be the way the API is meant to be used.


MS Manivel Sellamuthu Syncfusion Team October 4, 2019 03:48 AM UTC

 
Thanks for your update. 
 
We havevalidated your requirement. you can expand multiple levels by nesting the expand param. Please find the below nested expand query. 
 
 this.query = new Query().expand('Products($expand=Customer)');  
 
Please get back to us, if you need further assistance. 
 
Regards, 
Manivel 


Loader.
Live Chat Icon For mobile
Up arrow icon