How Do I Remove A Table Column In Mvc?
I want have two columns and based on a condition, include or remove a third. using all the if statements seems a bit redundant. Is there another way to do this? Copy
But if you want to remove the entire column, rather than inhibiting the display of the values, then if
statements are perfectly fine.
<tr><td><%= Model.Name.ToString().Trim() %></td><td><%= Model.Age.ToString().Trim() %></td>
<% if (myCondition) { %>
<td><%= Model.Other.ToString().Trim() %></td>
<% } %>
</tr>
By the way, it appears from your code sample that you need a loop. You could also benefit from some Html encoding. Something like this:
<% foreach (Person item inModel) { %>
<tr><td><%= Html.Encode(item.Name) %></td><td><%= Html.Encode(item.Age) %></td>
<% if (myCondition) { %>
<td><%= Html.Encode(item.Other) %></td>
<% } %>
</tr>
<% } %>
Solution 2:
if you are using table then hide the column showing Other value:
<% for(......){
//evaluate here if you will show it or not?var showOther = Age > 18 ? "block":"none";
%>
<tr><td>..</td><td>..</td><tddisplay="<%= showOther %>">..</td></tr>
<% }%>
Element?
I have a table and I need the cells to have an element posi…
Here's a js fiddle of what I currently have, I am tryin…
So I have a few pictures that I want to randomly generate o…
This is my first question. I usually try to research these …
Right Floated Element Disappears When Using Columns In Firefox
I am using an ol element with column-count and column-gap p…
Setting Link Href From Child Image Src Using JQuery
I am using .wrap() to create a link around each image withi…
How To Limit The Html Table Records In Each Page
I am populating a table in my jsp which has more than 20 re…
I want to show countdown in each of my divs. Right now I ge…
Retain Dynamically Created DropDown List's Selected Value On Event Window.history.back()- JavaScript
Can use the below question as a reference to explain the co…
|
Post a Comment for "How Do I Remove A Table Column In Mvc?"