Learn easyui questions (3) and learn easyui questions

Source: Internet
Author: User

Learn easyui questions (3) and learn easyui questions

Another problem I encountered in easyui today is: how to create a table?
First, the definition method provided on the easyui Chinese official website is as follows:

<!--table--><table id="tt"></table>
<! -- Script --> $ ('# tt '). datagrid ({url: 'datagrid _ data. json ',/* Data Transmission */columns: [{field: 'code', title: 'code', width: 100}, {field: 'name ', title: 'name', width: 100}, // note that there is no so-called unit {field: 'price', title: 'price', width: 100, align: 'right'}]});

This method can only be used to create a datagrid (table ):

However, it cannot be as effective as I want to create an excel table in a certain format. As follows:

That is to say, I want to customize the table format, which is easier to write directly using table in html, but easyui is used for the table style aesthetics, we have to write it in another way.
Next, I will introduce how to solve this problem-create a table
The Code is as follows:

 1 <table class="easyui-datagrid" style="width:400px;height:250px"   2         data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">   3     <thead>   4         <tr>   5             <th data-options="field:'code',width:100">Code</th>   6             <th data-options="field:'name',width:100">Name</th>   7             <th data-options="field:'price',width:100,align:'right'">Price</th>   8         </tr>   9     </thead>  10 </table>  

As follows:

Paste my table code:

<Table class = "easyui-datagrid" style = "width: 300px; height: 200px;" data-options = "url: 'datagrid _ data. json', fitColumns: true, singleSelect: true "> <! -- Url is not used here --> <thead> <tr> <th data-options = "field: 'code', width: 100 "> Code </th> <th data-options =" field: 'name', width: 100 "> name </th> <th data-options =" field: 'price', width: 100, align: 'right' "> Price </th> </tr> </thead> <tfoot> </tfoot> <tbody> <tr> <td> _ code </td> <td> _ name </td> <td> _ price </td> </tr> </tbody> </table>

In this way, we can easily create the table format and apply the easyui ui. Like one !!

Hope this article will help you!

Long live sharing !!

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.