Gnezdena tabela
 
mistique 15. apr 2015 08:28:41 Pridružen od:
1. okt 2008
1052 objav
916 63 7
#1

Potreboval bi pomoč pri preoblikovanju tabele. Imam tabelo, ki se lomi čez več strani, kar sem rešil s thead in tbody elementi. Ker pa je znotraj tabele še nested table, ki sem ga ločil od header-ja tabele, imam problem z uskladitvijo širin stolpcev table header-ja (fiksni stolpci) in table body-ja (dinamični).

V body se podatki polnijo dinamično in ko se tabela lomi čez dve strani, se na naslednji strani header in body prekrivata, kar je problem.



Vprašanji sta torej dve:

- kako uskladiti stolpce header-ja in body-ja?

- kako urediti kodo, da se na novi strani header in body ne prekrivata?



Spodaj je še koda:



<table class="10cols">

<thead>

<tr class="firstrow">

<td colspan="8"></td>

<td>Text text</td>

<td>Text text</td>

</tr>

<tr class="secondrow">

<td> </td>

<td>Text</td>

<td>Text</td>

<td> </td>

<td>Text</td>

<td>Text</td>

<td>Text</td>

<td>Text</td>

<td> </td>

<td> </td>

</tr>

</thead>

<tbody>

<tr class="datarow">

<td colspan="8">

<table>


                    @foreach (var variable1 in ABCWeb.TemplateHelper.MultiselectGetValues((string)ViewData["variable2"], "variable1"))
{
<tr>
<td class="width5">Text</td>
<td>@CheckNode(variable1, "variable1_variable3")</td>
<td class="width10">Text</td>
<td class="width5 textCenter">Text</td>
<td>@CheckNode(variable1, "variable1_varibale4")</td>
<td class="width10">Text</td>
<td class="width10">@CheckNode(variable1, "variable1_0")</td>
<td class="width20">@CheckNode(variable1, "variable1_variable5")</td>
</tr>
}
</table>
</td>

@{
var elemCount = ABCWeb.TemplateHelper.MultiselectGetValues((string)ViewData["variable2"], "variable1").Count;
}
<td rowspan="@elemCount" class="textCenter width15">@(ViewData["variable6"])</td>
<td rowspan="@elemCount" class="textCenter width15">@(ViewData["variable7"])</td>
</tr>
</tbody>
</table>
všeč(0) ni všeč(0) spam(0)
Give a man a fish, and he'll eat for a day. Teach him how to fish and he'll eat forever
 
mistique 15. apr 2015 13:24:01 Pridružen od:
1. okt 2008
1052 objav
916 63 7
#2

Nevermind. Mi je uspelo tabelo prestrukturirati tako, da so prelomi delali pravilno, pa tudi stolpci so poravnani.



Buyaka!


všeč(0) ni všeč(0) spam(0)
Give a man a fish, and he'll eat for a day. Teach him how to fish and he'll eat forever
 
krejzi 15. apr 2015 16:15:13 Pridružen od:
14. mar 2013
558 objav
915 213 12
#3

mistique:

Nevermind. Mi je uspelo tabelo prestrukturirati tako, da so prelomi delali pravilno, pa tudi stolpci so poravnani.



Buyaka!




Fajn je, da napišeš rešitev, če bo slučajno nekdo drug iskal podobno stvar ...


všeč(1) ni všeč(0) spam(0)
 
mistique 15. apr 2015 18:49:32 Pridružen od:
1. okt 2008
1052 objav
916 63 7
#4

Se strinjam, vendar, ker sem mislil, da gre za precej specifičen primer, nisem pisal podrobnosti.

Naredil pa sem redesign tabele. Na kratko (jutri prilepim kodo):




  • header sem spravil v eno vrstico

  • odstranil sem nested tabelo

  • odstranil rowspan (vsebina je sedaj v vsaki vrstici)


všeč(0) ni všeč(0) spam(0)
Give a man a fish, and he'll eat for a day. Teach him how to fish and he'll eat forever
 
mistique 16. apr 2015 06:06:55 Pridružen od:
1. okt 2008
1052 objav
916 63 7
#5

Evo, tabela je sedaj takšna:



<table class="10cols">

<thead>

<tr class="firstrow">

<td class="textBold"> </td>

<td class="textBold">Text</td>


<td class="textBold">Text</td>

<td class="textBold"> </td>

<td class="textBold">Text</td>

<td class="textBold">Text</td>

<td class="textBold">Text</td>

<td class="textBold">Texttd>

<td class="textBold">Text</td>

<td class="textBold">Text</td>


</tr>

</thead>

<tbody>

<tr>


                    @foreach (var getdate() in ABCWeb.Common.TemplateHelper.MultiselectGetValues((string)ViewData["variable2"], "variable1"))
{
<tr>
<td class="width5">Text</td>
<td>@CheckNode(variable1, "variable1_variable3")</td>
<td class="width10">Text</td>
<td class="width5 textCenter">Text</td>
<td>@CheckNode(variable1, "variable1_variable4")</td>
<td class="width10">Text</td>
<td class="width10">@CheckNode(variable1, "variable1_0")</td>
<td class="width20">@CheckNode(variable1, "variable1_variable5")</td>
@{
var elemCount = BPMWeb.TemplateHelper.MultiselectGetValues((string)ViewData["variable2"], "variable1").Count;
}
<td class="textCenter width15">@(ViewData["variable6"])</td>
<td class="textCenter width15">@(ViewData["variable7"])</td>
</tr>
}
</tr>
</tbody>
</table>
všeč(0) ni všeč(0) spam(0)
Give a man a fish, and he'll eat for a day. Teach him how to fish and he'll eat forever
 
 

🔒 Za odgovor na to temo se moraš prijaviti.

Prijavi se