2009-08-04 11 views
0

Ich möchte das ASP.NET DataGrid-Web-Steuerelement erweitern, um viele zusätzliche Features hinzuzufügen, aber am wichtigsten ist, möchte ich den Körper des Rasters scrollbar machen.Erweitern von DataGrid

Ich habe den HTML-Code ausgearbeitet, aber das Überschreiben des Steuerelements ist verwirrend. Die Grundstruktur der endgültigen Kontrolle sollte wie so aussehen:

<div id="grid1" class="grid"> 
<div class="grid-header"> 
    <div class="grid-header-l"></div> 
    <div class="grid-header-c"> 
     <div class="grid-header-wrapper"> 
      <div class="wrapper">Grid Header</div> 
     </div> 
    </div> 
    <div class="grid-header-r"></div> 
</div> 
<div class="grid-body"> 
    <div class="grid-column-headers"> 
     <div class="grid-column-headers-l"></div> 
     <div class="grid-column-headers-c"> 
      <div class="grid-column-headers-wrapper"> 
       <table class="grid-column-header-table" cellpadding="0" cellspacing="0" border="0"> 
        <tbody> 
         <tr> 
          <td> 
           <div class="grid-column-header-cell asc"> 
            <div class="grid-column-header-cell-wrapper"> 
             <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div> 
             <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a> 
             <div class="grid-column-header-divider"></div> 
            </div> 
           </div> 
          </td> 
          <td> 
           <div class="grid-column-header-cell"> 
            <div class="grid-column-header-cell-wrapper"> 
             <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div> 
             <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a> 
             <div class="grid-column-header-divider"></div> 
            </div> 
           </div> 
          </td> 
          <td class="last"> 
           <div class="grid-column-header-cell"> 
            <div class="grid-column-header-cell-wrapper"> 
             <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div> 
             <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a> 
             <div class="grid-column-header-divider"></div> 
            </div> 
           </div> 
          </td> 
         </tr> 
        </tbody> 
       </table> 
      </div> 
     </div> 
     <div class="grid-column-headers-r"></div> 
    </div> 
    <div class="grid-body-content"> 
     <div class="grid-body-content-t"> 
      <div class="grid-body-content-t-l"></div> 
      <div class="grid-body-content-t-c"></div> 
      <div class="grid-body-content-t-r"></div> 
     </div> 
     <div class="grid-body-content-m"> 
      <div class="grid-body-content-m-l"></div> 
      <div class="grid-body-content-m-c"> 
       <div class="grid-body-content-wrapper"> 
        <div class="scroll-wrapper"> 
         <table class="grid-content-table" cellpadding="0" cellspacing="0" border="0"> 
          <tbody> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
           <tr> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
            <td> 
             <div class="grid-content-cell">Cell Text/Value</div> 
            </td> 
           </tr> 
          </tbody> 
         </table> 
        </div> 
       </div> 
      </div> 
      <div class="grid-body-content-m-r"></div> 
     </div> 
     <div class="grid-body-content-b"> 
      <div class="grid-body-content-b-l"></div> 
      <div class="grid-body-content-b-c"></div> 
      <div class="grid-body-content-b-r"></div> 
     </div> 
    </div> 
</div> 

Wer weiß, was der beste Ansatz sein sollte? Kann mir jemand auf ein Tutorial hinweisen? Mir ist aufgefallen, dass der Autor den gerenderten HTML-Code erfasst hat, bevor er an den Antwortstream gesendet und geändert wurde. Ich benutze diesen Ansatz jedoch nicht gerne.

Antwort

0

Da ich nur die Ausgabe des Steuerelements ändern wollte, bedeutete das Erweitern des Steuerelements, dass ich nur das Rendering überschreiben musste.

Ich habe Artikel über Steueradapter gefunden, mit denen man die Ausgabe ändern kann. Ein Projekt existiert unter CodePlex mit dem Namen 'CSS Control Adapters'. Es war sehr hilfreich bei mehr Steuerelementen als nur das DataGrid.

1

Sie können versuchen this Ansatz. Funktioniert gut für mich.