I have a created a table with the repeater, im using itemtemplate and alternatingtemplate.
The item template creates the tabelrow tag and the alternating template closes the tablerow tag.
Here’s an example(I will provide the code further down)
Cells 1 to 3 is created by itemtemplate and 4 to 6 with alternating template.
Cells 1 – 3 has data_id 5
Cells 4 – 6 has data_id 2
Next row
Cells 1 – 3 has data_id 7
Cells 4 – 6 has data_id 3
Looking like this
Created first loop with repeater
|Cell1|_Cell2_|Cell3|_Cell4_|Cell5|_Cell6_|
Created second loop with repeater
|Cell1|_Cell2_|Cell3|_Cell4_|Cell5|_Cell6_|
End result
|Cell1|_Cell2_|Cell3|_Cell4_|Cell5|_Cell6_|
|Cell1|_Cell2_|Cell3|_Cell4_|Cell5|_Cell6_|
My questions is that I want too hide certain TD’s with Jquery. Let’s say I want to hide all TD with data-id= 2, that would be cells 4 to 6 first row.
How can I accomplish that without breaking the table structure, best would be to move everything like this.
Get rid of cells 4 to 6 first row
|Cell1|_Cell2_|Cell3|_Cell4_|Cell5|_Cell6_|
|Cell1|_Cell2_|Cell3|_Cell4_|Cell5|_Cell6_|
This is what it looks after removal for me..
|Cell1|_Cell2_|Cell3|
|Cell1|_Cell2_|Cell3|_Cell4_|Cell5|_Cell6_|
I want it to look like this
|Cell1|_Cell2_|Cell3||Cell1|_Cell2_|Cell3|
|Cell4|_Cell5_|Cell6|
Is that even possible?
Here’s my code..
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table cellspacing="0">
<thead>
<tr>
<th scope="col" abbr="Sidor/Artiklar" class="nobg">Sidor/Artiklar</th>
<th scope="col" abbr="Dual 1.8GHz">MozRank</th>
<th scope="col" abbr="Dual 1.8GHz">PR</th>
<th scope="col" abbr="Dual 1.8GHz">Fri tillgång</th>
<th scope="col" abbr="Dual 2GHz">30 Artiklar(1 om dagen)</th>
<th scope="col" colspan="2" abbr="Dual 2.5GHz">Välj själv</th>
<th scope="col" abbr="Sidor/Artiklar" class="nobg">Sidor/Artiklar</th>
<th scope="col" abbr="Dual 1.8GHz">MozRank</th>
<th scope="col" abbr="Dual 1.8GHz">PR</th>
<th scope="col" abbr="Dual 1.8GHz">Fri tillgång</th>
<th scope="col" abbr="Dual 2GHz">30 Artiklar(1 om dagen)</th>
<th scope="col" colspan="2" abbr="Dual 2.5GHz">Välj själv</th>
</tr>
</thead>
</HeaderTemplate>
<AlternatingItemTemplate>
<th scope="row" class="spec"><%# DataBinder.Eval(Container.DataItem, "namn_domain")%> </th>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<%# DataBinder.Eval(Container.DataItem, "moz_domain")%>
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<input type='<%# DataBinder.Eval(Container.DataItem, "type_domain")%>' name='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' value='<%# DataBinder.Eval(Container.DataItem, "faccess_domain")%>' onclick="calculatePrice();disableTB(this.name);" /> "Fri tillgång"
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<input type="radio" name='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' value='<%# DataBinder.Eval(Container.DataItem, "monthly_domain")%>' onclick="calculatePrice();disableTB(this.name);" /> "En artikel om dagen (30/mån)"
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<input type="radio" name='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' value="0" onclick="calculatePrice();enableTB(this.name, this.checked)" /> "Skriv ditt antal själv"
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<input type="text" name='<%# DataBinder.Eval(Container.DataItem, "moz_domain")%>' id='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' Enabled="false" Width="40px" onkeyup="calculatePrice()" style="background-color:#eeeeee" />
</td>
</tr>
</AlternatingItemTemplate>
<ItemTemplate>
<tr>
<th scope="row" abbr="Model" class="spec"><%# DataBinder.Eval(Container.DataItem, "namn_domain")%> </th>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<%# DataBinder.Eval(Container.DataItem, "moz_domain")%>
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<b></b>
<input type='<%# DataBinder.Eval(Container.DataItem, "type_domain")%>' name='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' value='<%# DataBinder.Eval(Container.DataItem, "faccess_domain")%>' onclick="calculatePrice();disableTB(this.name);" /> "Fri tillgång"
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<input type="radio" name='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' value='<%# DataBinder.Eval(Container.DataItem, "monthly_domain")%>' onclick="calculatePrice();disableTB(this.name);" /> "En artikel om dagen (30/mån)"
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<input type="radio" name='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' value="0" onclick="calculatePrice();enableTB(this.name, this.checked)" /> "Skriv ditt antal själv"
</td>
<td class="alt" data_id='<%# DataBinder.Eval(Container.DataItem, "pr_domain")%>'>
<input type="text" name='<%# DataBinder.Eval(Container.DataItem, "moz_domain")%>' id='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' Enabled="false" Width="40px" onkeyup="calculatePrice()" style="background-color:#eeeeee" />
</td>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
This is my jquery, just messing about getting to understand the function, so this code is obviously not the correct
function hidetd() {
for(var i = 0; i < 2; i++) {
$("[data_id=" + i + "]").hide();
}
}
For loop is not required in your case. The following jQuery code snippet will hide all the td elements with attribute data_id = 2