Zum Inhalt springen

fixxer Tabellenkopf, scrollbarer Inhalt


Empfohlene Beiträge

Geschrieben

hi,

ich überleg grad wie ich die kopfzeile (spaltennamen) einer tabelle immer am oberen bildschirmrand behalte, im tabelleninhalt aber beliebig nach oben und unten scrollen kann. für beides hab ich ne eigene funktion die ich in frames setzen könnte, aber vllt gibt`s ja noch ne schönere lösung?

---------------------

Name | Vorname | Ort

---------------------

---------------------

Wurst| Hans | town >

zeiss | Carl | city > <-- scrollbar

kuhn | peter | stadt >

Geschrieben

ich bezweifle, ob es von der performance und übersichtlichkeit sinn macht, tausende datensätze zu laden und anzuzeigen.

wie wärs, wenn du die zeilen zum seitenweise in, sagen wir mal, 25er schritten durchblättern machst?

s'Amstel

Geschrieben
wenn ich bei tausenden einträgen runterscrolle verschwindet logischerweise der kopf mit den spaltennamen und genau das soll nicht passieren.

dann hatte ich dich wohl wirklich falsch verstanden :)

Du meinst quasi so eine Funktion wie in Excel.

Geschrieben

funktioniert im IE, leider nicht im FF; dafür kann FF aber div-Container mit position: fixed richtig darstellen ;)

Beispiel-Code (net schön, net sauber, funktioniert aber, eben kurz runtergeschrieben)

seite.html


<html >

<head>

    <title>Tabellenlayout TEST</title>

    <link rel="stylesheet" type="text/css" href="style.css" />

</head>


<body>


<table cellpadding="0" cellspacing="0">

    <tr>

        <td id="top" colspan="2"> 

	Überschrift

        </td>

    </tr>

    <tr>

        <td id="left">

            Menü<br />

        </td>

        <td>

            <div id="content">

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />

		foobar<br />


            </div>

        </td>


    </tr>

</table>


</body>

</html>

style.css

*

{

	font-family: Tahoma, Verdana, Arial;

	color: #ffffff;

	font-size: 10pt;

	text-decoration: none;

}


body 

{

	margin: 0px;

	overflow: hidden;

}


#top

{

	background-color: #232323;

	background-image: url("../Images/logo_top.jpg");

	height: 79px;

	overflow: hidden;

	font-size: 20px;

	font-decoration: bold;

	text-align: center;

}


#left

{

	background-color: #232323;

	width: 100px;

	vertical-align: top;

}



#content

{

	color: #424242;

	text-align: center;

	overflow: auto;

	position: static;

	height: 100%;

	width: 100%;

	padding: 20px;

}


table

{

	width: 100%;

	height: 100%;

}


Geschrieben

cool danke jan.

http://www.homepage-total.de/css/scrollende-tabelle.php

ich hab grad nur schwierigkeiten das umzusetzen.


echo "<table ......>";

$tabellenkopf="<tr>";
for($i=0;$i<=25;$i++)
{
$tabellenkopf.= "<td>Feldname</td>";
}
$tabellenkopf.="</tr>";

for($i=0;$i<mysql_num_rows($result);$i++)
{
$tabelleninhalt.="<tr><td>Datensatz</td></tr>";
}

echo "<pre style='margin: 0px;'>";
echo $tabellenkopf;
echo "</pre>";

echo "<div style='height: 150px; overflow: auto;'>";
echo $tabelleninhalt;
echo "</div>";

echo "</table>";
[/PHP]

cool wär wenn ich die beiden arrays (?) in die zwei "container" packen könnte ohne viel umzuschreiben. ungefähr so wie oben versucht.

Geschrieben

moep ist ja klar warum das bei mir nicht funktionieren kann ^^

im beispiel gibt es zwei tabellen die unabhängig von einander sind. bei mir schreib ich alles in eine, um für jeder spalte die richtige breite zu haben (feldname <-> spalteninhalt).

Geschrieben

warum kann es nicht so einfach sein jan?


echo "<table cellpadding='0' cellspacing='0'>";
echo "<tr>";
echo "<td id='top'>";
echo $tabellenkopf;
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>";
echo "<div id='content'>";
echo $tabelleninhalt;
echo "</div>";
echo "</td>";
echo "</tr>";
echo "</table>";
[/PHP]

Geschrieben

was genau funktioniert denn nicht, der Ansatz ist schon in Ordnung so,

allerdings müsstest du für die Daten in der Tabelle zwei geschachtelte Schleifen verwenden, weil du ja Spalten und Zeilen füllen musst.

also etwa so:


echo "<table border='1'>";


$tabellenkopf="<tr>";

for($i=0;$i<=3;$i++)

{

  $tabellenkopf.= "<th>Feldname $i</th>";

}

$tabellenkopf.="</tr>";


for($i=0;$i<=3;$i++)

{

	$tabelleninhalt .= "<tr>";

	for($j=0;$j<=3;$j++)

	{

		$tabelleninhalt .= "<td>Datensatz Zeile: $i Spalte: $j</td>";

	}

	$tabelleninhalt .= "</tr>";

}


echo "<pre style='margin: 0px;'>";

  echo $tabellenkopf;

echo "</pre>";


echo "<div style='height: 150px; overflow: auto;'>";

  echo $tabelleninhalt;

echo "</div>";


echo "</table>";

PS: Tabellenüberschriften übrigens mit th, nicht td ;)

Geschrieben

na ja ich bekomm keine zwei sauberen container hin.. die höhe die ich im zweiten container (inhalt) angebe, wird als abstand zum oberen bildschirmrand genommen...und abgesehen von dem "abstand" hat sich nichts an meiner ansicht verändert.

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...