This question is locked. New answers and comments are not allowed.
Hi. I've been searching through Telerik pages and Google for a solution to this but haven't found anything really that would help me, so here it goes.
I made a model with Telerik ORM and am using a Grid to show data.
I have one many-to-many relationship between two tables (Books and Borrowing - application is for a library).
If I want to access a list of books that are associated with a single borrowing i can do this by referencing an association between those tables. Association returns a list of Book objects, and from there I can access a single book and all of its property's.
What I want is to be able to show all of the books associated with a single borrowing in one row. One row for one borrowing in a Grid that binds its data from Borrowings table.
Best I could manage is to index the association witch returns a single book, like so:
Borrowings.Books[0].ID
But I don't know how to go through the entire list of Books (through all the indexes that the association returns) and write, say, the Author of all related Books in a single row (which represents a single borrowing).
I tried using a for and foreach loops but don't know how to put them inside a grid (if that's even possible), and I was looking at IEnumerator/GetEnumerator() but don't know if I'm using it right. I am pretty new to Telerik extensions for MVC btw.
Tnx for your answers and any help would be appreciated.
Edit:
If anyone's interested, I have managed to find a way of some sorts. This is the code I used:
I made a model with Telerik ORM and am using a Grid to show data.
I have one many-to-many relationship between two tables (Books and Borrowing - application is for a library).
If I want to access a list of books that are associated with a single borrowing i can do this by referencing an association between those tables. Association returns a list of Book objects, and from there I can access a single book and all of its property's.
What I want is to be able to show all of the books associated with a single borrowing in one row. One row for one borrowing in a Grid that binds its data from Borrowings table.
Best I could manage is to index the association witch returns a single book, like so:
Borrowings.Books[0].ID
But I don't know how to go through the entire list of Books (through all the indexes that the association returns) and write, say, the Author of all related Books in a single row (which represents a single borrowing).
I tried using a for and foreach loops but don't know how to put them inside a grid (if that's even possible), and I was looking at IEnumerator/GetEnumerator() but don't know if I'm using it right. I am pretty new to Telerik extensions for MVC btw.
Tnx for your answers and any help would be appreciated.
Edit:
If anyone's interested, I have managed to find a way of some sorts. This is the code I used:
.CellAction(cell => { if (cell.Column.Title == "Books") { for (int i = 0; i < cell.DataItem.Books.Count; i++) { if(i%2 == 1){ cell.Text += "<div style='color:Red'>" + cell.DataItem.Books[i].Title + "</div>"; }else{ cell.Text += "<div style='color:Blue'>" + cell.DataItem.Books[i].Title + "</div>"; } } } })