Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

jQuery EasyUI Data Grid - Transform HTML tables into data grids


May 09, 2021 jQuery EasyUI


Table of contents


jQuery EasyUI Data Grid - Transform HTML tables into data grids

This section describes the use of the jQuery EasyUI data grid, which focuses on how to convert HTML tables into data grids.

This example shows how to convert a table to a data grid.

jQuery EasyUI Data Grid - Transform HTML tables into data grids

The column information for the datagrid is defined in the tag, and the data is defined in the tag. To make sure you set the field name for all data columns, look at the following example:

	<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>

You can then define a complex header, such as:

	<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>

Now you can see that the complex header has been created.

jQuery EasyUI Data Grid - Transform HTML tables into data grids

Download the jQuery EasyUI instance

jeasyui-datagrid-datagrid1.zip