文檔首頁>>jQuery EasyUI使用教程>>jQuery EasyUI使用教程:將一個HTML表格轉(zhuǎn)換為數(shù)據(jù)網(wǎng)格
jQuery EasyUI使用教程:將一個HTML表格轉(zhuǎn)換為數(shù)據(jù)網(wǎng)格
Kendo UI for jQuery——創(chuàng)建現(xiàn)代Web應(yīng)用程序的最完整UI庫!查看詳情>>>
本教程將為大家演示如何將一個表格轉(zhuǎn)換為數(shù)據(jù)網(wǎng)格。
該數(shù)據(jù)網(wǎng)格的列被定義在< thead>標(biāo)記中,而數(shù)據(jù)則被定義在< tbody>標(biāo)記中。確保為每一個數(shù)據(jù)列設(shè)置字段名稱,請看下面的示例:
<table id="tt" class="easyui-datagrid" style="width:400px;height:auto;"> <thead> <tr> <th field="name1" width="50">Col 1</th> <th field="name2" width="50">Col 2</th> <th field="name3" width="50">Col 3</th> <th field="name4" width="50">Col 4</th> <th field="name5" width="50">Col 5</th> <th field="name6" width="50">Col 6</th> </tr> </thead> <tbody> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> <td>Data 4</td> <td>Data 5</td> <td>Data 6</td> </tr> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> <td>Data 4</td> <td>Data 5</td> <td>Data 6</td> </tr> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> <td>Data 4</td> <td>Data 5</td> <td>Data 6</td> </tr> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> <td>Data 4</td> <td>Data 5</td> <td>Data 6</td> </tr> </tbody> </table>
當(dāng)然你還可以定義一個復(fù)雜的表頭,例如:
< thead> < tr> < th field="name1" width="50" rowspan="2">Col 1</th> < th field="name2" width="50" rowspan="2">Col 2</th> < th field="name3" width="50" rowspan="2">Col 3</th> < th colspan="3">Details</th> < /tr> < tr> < th field="name4" width="50">Col 4</th> < th field="name5" width="50">Col 5</th> < th field="name6" width="50">Col 6</th> < /tr> < /thead>
現(xiàn)在你可以看到,復(fù)雜的表頭已經(jīng)創(chuàng)建好了。
下載該EasyUI示例:easyui-datagrid-demo.zip
購買最新正版授權(quán)!"咨詢在線客服"