Jquery Easyui Datagrid創建代碼

引用easyui

  1. <link rel="stylesheet" type="text/css" href="../themes/default/easyui.css"> 
  2. <link rel="stylesheet" type="text/css" href="../themes/icon.css"> 
  3. <link rel="stylesheet" type="text/css" href="demo.css"> 
  4. <script type="text/javascript" src="../jquery-1.7.2.min.js"></script> 
  5. <script type="text/javascript" src="../jquery.easyui.min.js"></script> 

javascript代碼

  1. $(function(){  
  2.     $('#tt').datagrid({  
  3.         url:'datagrid_data2.json',  
  4.         columns:[[  
  5.             {   field:'productid',  
  6.                 title:'Product ID',  
  7.                 width:120  
  8.                 //rowspan:2  
  9.                 //colspan:2  
  10.                 //align:'center'  
  11.                 //sortable:true  
  12.                 //resizable:true  
  13.                 //hidden:true  
  14.                 //checkbox:true  
  15.                 //formatter:function(value,row,index){}  
  16.                 //styler:function(value,row,index){}  
  17.                 //sorter:function(a,b){ }  
  18.                 //editor:string,object  
  19.  
  20.             },  
  21.               
  22.             {field:'listprice',title:'List Price',width:80,align:'right'},  
  23.             {field:'unitcost',title:'Unit Cost',width:80,align:'right'},  
  24.             {field:'attr1',title:'Attribute',width:250},  
  25.             {field:'status',title:'Status',width:60,align:'center'}  
  26.         ]],  
  27.         frozenColumns:[[  
  28.                {field:'ck',checkbox:true},  
  29.                {field:'itemid',title:'Item ID',width:80,sortable:true}  
  30.         ]],  
  31.         //fitColumns:false,//true會導致列錯位  
  32.         //autoRowHeight:true,  
  33.         toolbar:[{  
  34.             iconCls: 'icon-edit',  
  35.             text:'編輯',  
  36.             handler: function(){alert('edit')}  
  37.         },'-',{  
  38.             iconCls: 'icon-help',  
  39.             text:'幫助',  
  40.             handler: function(){alert('help')}  
  41.         }],  
  42.         //striped:true,//條紋行,以區分行  
  43.         //method:'post',  
  44.         //nowrap:true,//false設置數據自動換行  
  45.         //idField:'itemid',  
  46.         loadMsg:'請稍候...',  
  47.         pagination:true,//分頁欄  
  48.         rownumbers:true,//第一列顯示自增序列  
  49.         singleSelect:true 
  50.         //checkOnSelect:true,  
  51.         //selectOnCheck:true,  
  52.         //pagePosition:'both',  
  53.         //pageNumber:1,  
  54.         //pageSize:10,  
  55.         //pageList:[10,20,30,40,50],  
  56.         //queryParams: {  
  57.         //  name: 'easyui',  
  58.         //  subject: 'datagrid'  
  59.         //},  
  60.         //sortName:'itemid',  
  61.         //sortOrder:'desc',  
  62.         //remoteSort:false,//true發送命令到服務器請求排序數據,false本地自己排序  
  63.         //showHeader:true,  
  64.         //showFooter:true,  
  65.         //scrollbarSize:18,  
  66.         //rowStyler:function(index,row,css){}  
  67.         //loader:'json loader',  
  68.         //loadFilter:function(data){}  
  69.         //editors:'predefined editors',  
  70.         //view:'default view'  
  71.     });  
  72.     //設置分頁控件     
  73.     $('#tt').datagrid('getPager').pagination({     
  74.         pageSize: 10,//每頁顯示的記錄條數,默認爲10     
  75.         pageList: [5,10,15],//可以設置每頁記錄條數的列表     
  76.         beforePageText: '第',//頁數文本框前顯示的漢字     
  77.         afterPageText: '頁    共 {pages} 頁',     
  78.         displayMsg: '當前顯示 {from} - {to} 條記錄   共 {total} 條記錄'   
  79.         /*onBeforeRefresh:function(){    
  80.             $(this).pagination('loading');    
  81.             alert('before refresh');    
  82.             $(this).pagination('loaded');    
  83.         }*/    
  84.     });   
  85. }); 


 

html代碼

  1. <table id="tt"></table> 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章