學習easyui疑問(三),學習easyui疑問

來源:互聯網
上載者:User

學習easyui疑問(三),學習easyui疑問

今天我學習easyui中碰到的另一問題是:如何建立一個表格?
首先,在easyui中文官網上提供的這樣一種定義方式:

<!--table--><table id="tt"></table>
<!--script-->$('#tt').datagrid({    url:'datagrid_data.json',  /*這裡用於傳資料*/    columns:[[        {field:'code',title:'Code',width:100},        {field:'name',title:'Name',width:100},//需要特別注意這裡沒有所謂的單位        {field:'price',title:'Price',width:100,align:'right'}    ]]});

這種方式只能用於建立的datagrid(也就是我們所說的table):

而不能達到我所想要打有一定格式的excel表效果。如下:

也就是說我想要自訂表格格格式,這在html中直接用table來寫還是比較容易實現的,但為了table的樣式美觀性,用到easyui,我們就必須換種方式來寫。
接下來,我就給大家介紹一下解決這個問題的方式—在table中進行建立
代碼如下:

 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>  

如下:

貼一下我的table代碼:

 <table class="easyui-datagrid" style="width: 300px; height: 200px;" data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true"> <!--url這裡並無卵用-->                <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>

這樣我們就既比較容易建立table格式,又可以應用easyui的ui介面了。贊一個!!

望此文能協助你!

分享萬歲!!

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.