2
votes

I want to do list operations in the kendo grid.

Say I have below models,

public Class Product{
   int id {get;set;}
   List<Part> parts {get;set;}
}

public class part{
   int id {get;set;}
   string partName {get;set;}
}

Each product has the list of parts and each part has its properties described in the model above.

I would like to list all the products with their parts property as each kendo column in the kendo grid and have an issue in fetching the partName of the inner model by passing list of Product model to kendo grid.

Below is the way I am fetching inner model property to display for few column in the grid

columns.Bound(x => x.Parts.Find(x=>x.id=="1").partName)

please suggest if I am doing something wrong to fetch inner model properties.

Thanks in advance.

1
Your statement Model.SomeABCList.Find(x=>x.id="1").SomeValue suggests you already have SomeValue as a property on your model right? Then what's the issue you can directly use it. Also, there is no harm in adding a property as it just acts as a data carrier.Rahul Singh
@RahulSingh, I have to add 10 more properties which isn't a right way I feel.Viresh Mathad
@RahulSingh, And I have the value but how can I bind to the grid?Viresh Mathad
@VireshMathad - Where you have the value?Rahul Singh

1 Answers

0
votes

I ended up changing the structure, as we cannot bind a nested value of a list to a kendo grid column.

Took one more model as a replicate of columns I need to show in a kendo grid and assigned all the values in the backend.