Partial view in ASP.NET always outside of <tr> - asp.net

I am trying to render my partial view inside table row (which is inside thead tag) but I`m always have the view rendered outside of the row . Here is the code:
<tr id="lineTimes">
<th> <partial name="LineTimesRow" model="Model.LineTimes" /></th>
</tr>
Quick inspection of DOM shows following:
What even more strange is that if I put this partial view inside of tbody tag then it renders just fine:
<tbody id="lineTimes">
<partial name="LineTimesRow" model="Model.LineTimes" />
</tbody>
I`m trying to investigate this for like 5 hours - without any luck. Can someone point me to the right direction? Any help will be appreciated.
Here is the whole code snippet:
<table class="table table-sm table-hover text-center arrow-nav table-line-times">
<thead class="thead-dark">
<tr>
<th>
Artikel
</th>
<th>
</th>
<th>THT</th>
<th>lotsize</th>
<th title="Incr lotsize">incr</th>
#Html.DisplayFor(model => model.ViewHeader, "WeekplanningDateHeader")
</tr>
#*<tr id="lineTimes">
<th> <partial name="LineTimesRow" model="Model.LineTimes" /> </th>
</tr>*#
</thead>
<tbody id="lineTimes">
<partial name="LineTimesRow" model="Model.LineTimes" />
</tbody>
<tbody>
#Html.EditorFor(model => model.Days)
</tbody>
<tfoot></tfoot>
</table>
EDIT:
Fixed it - the issue was in the partial itself and my lack of understanding on how table nesting works. My partial were combined of table rows (tr) elements. And because I am trying to inject it into another table row (tr element) it is just ignored because tr cannot be inside another tr just "as is" - (nested tr needs to be wrapped in table). Mystery solved!

Fixed it - the issue was in the partial itself and my lack of understanding on how table nesting works. My partial were combined of table rows (tr) elements. And because I am trying to inject it into another table row (tr element) it is just ignored because tr cannot be inside another tr just "as is" - (nested tr needs to be wrapped in table). Mystery solved!

Related

The value in the td tag is not correspondingly above table head (react-bootstrap)

I am trying to create a table in reactjs using bootstrap. Everything seems fine except:
As you can see, the titles inside the thead tag is not aligned exactly above its corresponding td tag. Is there a way to do it?
Here is the code:
<Table striped hover responsive >
<thead>
<tr>
<th>Rank</th>
<th>Logo</th>
<th>Name</th>
<th ></th>
<th>Wins</th>
<th>Loss</th>
<th>Draws</th>
<th>Games</th>
<th>GF</th>
<th>GA</th>
</tr>
</thead>
<tbody>
{team && team.map((team, key) =>{
return <tr key={key}>
<td>{key + 1}</td>
<td><img src={team.team.logos[0].href} alt='team logo' width={40} height={40}/></td>
<td >{team.team.name}</td>
<td>{team.stats[0].value}</td>
<td>{team.stats[1].value}</td>
<td>{team.stats[2].value}</td>
<td>{team.stats[3].value}</td>
<td>{team.stats[4].value}</td>
<td>{team.stats[5].value}</td>
</tr>
})}
</tbody>
</Table>
I cannot see the code, but there seems to be some margin for the td. But you will still have issues with it lining up due to the number of words in td to the data listed. A solution would be styling each td by itself until you get it how you'd like.

semantic ui - how to style table headings

So I have built a table in semantic-ui. very simple. however styles dont seem to apply to my table in certain aspects and i cant get the headings to map over the columns. see the below screenshot
the L column is fine but the others are a bit wonky and name is just well off. how can i adjust the styles so make this work?
I have tried to add a width to the div my table sits in but it just extends it without altering the table body or head
here is the code:
<div className="tableContainer">
<h1> Table </h1>
<table className="ui striped table">
<thead>
<tr>
<th className="headings">Ranks</th>
<th className="headings">Name</th>
<th className="headings">P</th>
<th className="headings">W</th>
<th className="headings">L</th>
</tr>
</thead>
<tbody>
{this.props.players.sort(function(a, b) {
return (a.rank) - (b.rank);
}).map(function(player, index) {
index +=1;
return <tr key={index} className="table-rows">
<td className="stats">{player.rank}</td>
<td className="stats">{player.name}</td>
<td className="stats">{player.played}</td>
<td className="stats">{player.wins}</td>
<td className="stats">{player.losses}</td>
</tr>
}, this)}
</tbody>
</table>
</div>
If you are working in Reactjs, you should use Semantic-UI's reactjs package: Semantic-UI React. In the Table section, you can see that certain properties are passed through props. You can set the column number with columns prop. And under the Table.Header tab, you can see that there's a className prop. You can use it to style your header. For reference, visit: Semantic-UI React Table.

Changing CSS classes within Ember and SortMixin

I have a table which I have applied sorting to but to complete this task I would like the classes to change to show carets going up or down based on the sorting.
As you can see I have used the standard SortableMixin within Ember to get the sorting functionality but I'm having trouble changing the class of the individual element which has been clicked.
App.CampaignsController = Ember.ArrayController.extend({
sortProperties: ["id"],
sortAscending: true,
actions: {
sortBy: function(property){
if (this.get("sortProperties")[0] === property){
this.toggleProperty("sortAscending");
} else {
this.set("sortProperties", [property]);
this.set("sortAscending", true)
}
}
}
});
The table I'm I've applied the actions to is below:
<table class="table table-striped table-hover">
<thead>
<tr>
<th {{action "sortBy" "name"}}><i {{bind-attr class=":fa sortAscending:fa-caret-up:fa-caret-down"}}></i>Campaign Name</th>
<th {{action "sortBy" "campaign_code"}}><i {{bind-attr class=":fa sortAscending:fa-caret-up:fa-caret-down"}}></i>Campaign Code</th>
</tr>
</thead>
<tbody>
<td>{{name}}</td>
<td>{{campaign_code}}</td>
</tbody>
</table>
I'm using the sortAscending boolean to dictate what CSS class will appear. My problem is if I click the first heading, the classes on the second heading also change.
How do I get the CSS to change only on the heading that I have clicked?
Your <th> now has state (whether it's sorted, and whether it's ascending or descending), so you should wrap it up in a component. Something like this
<table>
<thead>
<tr>
{{#sortable-th property='name' action='sortBy'}}
Campaign Name
{{/#sortable-th}}
</tr>
</thead>
</table>
The component's template
// templates/components/sortable-th.js
<th>
<i {{bind-attr class=":fa sortAscending:fa-caret-up:fa-caret-down"}}></i>
{{yield}}
</th>
and code
// components/sortable-th.js
export default Ember.Component.extend({
sortAscending: true,
click: function() {
this.toggleProperty('sortAscending');
this.sendAction('action', this.get('property'), this.get('sortAscending'));
}
}
That's just a rough outline, try the implementation yourself. But that's how I would start thinking about it.

Ractivejs: How to get to work Nested properties in view

I have 2 objects results and headers being headers generated from _.keys(result[0])
r{
data:{
headers:['head1','head2']
result:[
{head1:'content1',head2:'content2'}
{head1:'content3',head2:'content4'}
{head1:'content5',head2:'content6'}
]
}
I have to create a table dinamically so I create this:
<table class="ui celled table segment">
<thead>
<tr>
{{#headers}}
<th>{{.}}</th>
{{/headers}}
</tr></thead>
<tbody>
{{#result:i}}
<tr>
{{#headers:h}}
<td>{{????}}</td> <-- Here is where I fail to know what to put into
{{/headers}}
</tr>
{{/result}}
</tbody>
</table>
Can someone help me to fill in the blanks. So I can create a table that display the contents
If I remove the {{#headers}} part and I already know the elements <td>{{.head1}}</td> work perfectly the problem is that I'am generating different objects on the fly.
{{#result:i}}
<tr>
{{#headers:h}}
<td>{{result[i][this]}}</td>
{{/headers}}
</tr>
{{/result}}
The reason this works is that the <td> is repeated for each item in the headers array, because it's inside a headers section - so far, so obvious. Because of that, we can use this to refer to the current header (head1, head2 etc). The trick is to get a reference to the current row - and because you've already created the i index reference, we can do that easily with result[i]. Hence result[i][this].
Here's a demo fiddle: http://jsfiddle.net/rich_harris/dkQ5Z/

Popovers don't work correctly on table rows using table-striped style

After upgrading to bootstrap 3 generating a popover on table rows has an unexpected hovering effect on the table row. Popovers don't behave correctly on table rows using table-striped style. Removal of the table-striped style is one fix but you lose that effect. Only tested in Chrome. The last working version was 2.1.1.
Bootstrap 2.2.2: http://jsfiddle.net/tomshaw/9N4fs/
Is there a way to give the popover a container to stop this effect? Or some similar technique?
<table class="table table-striped">
<thead>
<tr>
<th>Module</th>
<th>Controller</th>
<th>Action</th>
<th>Recorded</th>
</tr>
</thead>
<tbody>
<tr id="popover" data-content="Content One" title="System Information">
<td>Utilities</td>
<td>Transaction</td>
<td>Export</td>
<td>2012-12-26 11:58:10</td>
</tr>
<tr id="popover" data-content="Content Two" title="System Information">
<td>Utilities</td>
<td>Reports</td>
<td>Edit</td>
<td>2012-12-26 12:47:30</td>
</tr>
<tr id="popover" data-content="Content Three" title="System Information">
<td>Utilities</td>
<td>User</td>
<td>Edit</td>
<td>2012-12-26 12:48:27</td>
</tr>
</tbody>
</table>
// Weird table row table-striped hover effect. Broken in bootstrap
// 2.2.2 working in 2.1.1 Using selector option has same effect.
$('body').popover({placement:"top",trigger:"hover",selector:'tr[id=popover]'});
table {
margin:50px 5px 0 5px;
}
I'm not sure what behavior you are going for. When I removed the table-striped the behavior of the pop-up was the exact same. Also you are using mutliple ID tags with the same name in your tr s. I updated your example to fix a few of these things and I rearranged the popup to an area where I assumed that you wanted it. Let me know if that helps and please remember not to use multiple id's with the same name.
Here is what I did to move the popover:
Added:
.popover{
left: 0px !important;
}
Here is a working fiddle make sure you look at the changes in the HTML and the JS:
http://jsfiddle.net/9N4fs/30/

Resources