asp.net MVC EF와 easyui DataGrid 데이터 바인딩

9204 단어 datagrid
페이지 코드
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>PurchaseOrderDetail</title>
    <link href="~/Content/themes/blue/easyui.css" rel="stylesheet" />
    <link href="~/Content/themes/blue/icon.css" rel="stylesheet" />

    <script src="~/Scripts/jquery.min.js"></script>
    <script src="~/Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript">
        $(function () {

            $('#List2').datagrid({
                title: 'Checkbox selection on DataGrid',
                url: 'GetPurchaseOrder',
                method: 'get', //   post,          
                width: '700',
                iconCls: 'icon-save',
                dataType: "json",
                fitColumns: true,
                rownumbers: true, //      
                pagination: true, //       
                pageSize: 15, //   ,   pageList    ,      
                pageNumber: 2, //        
                pageList: [15, 30, 45],//           
                columns: [[
                    { field: 'ck', checkbox: true },
                    { field: 'PKID', title: 'id' },
                    { field: 'REAL_NAME', title: '  ' },
                    { field: 'MOBILE', title: '    ' },
                    { field: 'STAFF_CODE', title: '  ' }                
                ]],
                singleSelect: false, //      
                selectOnCheck: true,//true      ,false      , 1.3      
                checkOnSelect: true //true     ,false      , 1.3      
            });
        });
    </script>
</head>
<body>
    <div style="margin:10px 0;"></div>
       <table id="List2" class="easyui-datagrid"></table>  
</body>
</html>

 
  
 
컨트롤러
코드
 
 ZG_ERPEntities erp = new ZG_ERPEntities();



public JsonResult GetPurchaseOrder(int? page, int? rows)
{
page = page == null ? 1 : page;
rows = rows == null ? 1 : rows;
List<TSYS_USER> list = erp.TSYS_USER.OrderBy(a=>a.PKID).Skip((Convert.ToInt32(page) - 1) * Convert.ToInt32(rows)).Take( Convert.ToInt32(rows)).ToList();

var json = new
{
total = erp.TSYS_USER.Count(),
rows = (from r in list
select new TSYS_USER()
{
PKID=r.PKID,
REAL_NAME=r.REAL_NAME,
MOBILE=r.MOBILE,
STAFF_CODE=r.STAFF_CODE
}).ToArray()
};
return Json(json, JsonRequestBehavior.AllowGet);
}

 
 

  
 
예컨대

좋은 웹페이지 즐겨찾기