Dynamic Table ASP.NET MVC View Page

65 Views Asked by At

I am calling multiple API from the controller to get 3 different list of objects : the objects in the list are a Vehicle, an attributeNameType and a AttributeData The AttributeNametype is an object that has the name and type of a propriety which means am gonna use it to display the the name of a propriety created on the vehicle by the user on the view with the list of vehicles for example : vehicles has Model an a number, the user added a propriety color, this new added propriety will be stored in the AttributeNameType Column and the view page will display a list with all the vehicles so basically the element are gonna have Name,Model and Color. Until this part i can easily display the name of the headers for the table the problem i had was with displaying each line of data for each vehicles, is there a way to test for the name displayed for the type in this example check for "Color" so that i can add an 'IF block' to add the data corresponding the right column.

I tried using JavaScript but I cant use a Js function before pre-rendering. I tried sorting the list to display it but because this is only viable for the case where we add only one propriety as soon as i added a second one, the problem here was if there is no data in the first element the second element gets input there. so what am asking here is is there a way to use Javascript to check for the column while pre-rendering, or if you have any suggestion on how i can do this without Javascript?

0

There are 0 best solutions below