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>