Asp.net 如何将IEnumerable列表绑定到JQGrid
我需要使用ASP.NETMVC2将IEnumerable列表绑定到JQGrid。目前我有以下几点 型号:Asp.net 如何将IEnumerable列表绑定到JQGrid,asp.net,asp.net-mvc,asp.net-mvc-2,jqgrid,jqgrid-asp.net,Asp.net,Asp.net Mvc,Asp.net Mvc 2,Jqgrid,Jqgrid Asp.net,我需要使用ASP.NETMVC2将IEnumerable列表绑定到JQGrid。目前我有以下几点 型号: public class Client { public int ClientID { get; set; } [Required(ErrorMessage="Name Required")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string
public class Client
{
public int ClientID { get; set; }
[Required(ErrorMessage="Name Required")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string Name { get; set; }
public string Address { get; set; }
public string Mobile { get; set; }
public string Telephone { get; set; }
public string Fax { get; set; }
public string Company { get; set; }
}
存储库:
private StockDataClassesDataContext dc;
public IEnumerable<Client> GetClients()
{
dc = new StockDataClassesDataContext(ConString.DBConnection);
IEnumerable<Client> cli = (from tbclient in dc.tblClients
select new Client
{
Address = tbclient.Address,
ClientID = tbclient.ClientID,
Company = tbclient.Company,
Fax= tbclient.Fax,
Mobile = tbclient.Mobile,
Name = tbclient.Name,
Telephone = tbclient.Telephone
});
return cli;
}
public ActionResult Index()
{
JqGridClientRepository rep = new JqGridClientRepository();
IEnumerable<Client> clients = rep.GetClients();
return View(clients);
}
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<title>jqGrid for ASP.NET MVC - Demo</title>
<!-- The jQuery UI theme that will be used by the grid -->
<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/themes/redmond/jquery-ui.css" />
<!-- The Css UI theme extension of jqGrid -->
<link rel="stylesheet" type="text/css" href="../../Content/themes/ui.jqgrid.css" />
<!-- jQuery library is a prerequisite for jqGrid -->
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
<!-- language pack - MUST be included before the jqGrid javascript -->
<script type="text/javascript" src="../../Scripts/trirand/i18n/grid.locale-en.js"></script>
<!-- the jqGrid javascript runtime -->
<script type="text/javascript" src="../../Scripts/trirand/jquery.jqGrid.min.js"></script>
<h2>Index</h2>
</asp:Content>
private-StockDataClassesDataContext-dc;
公共IEnumerable GetClients()
{
dc=新StockDataClassesDataContext(consting.DBConnection);
IEnumerable cli=(来自dc.tblClients中的tbclient
选择新客户端
{
地址=tbclient.Address,
ClientID=tbclient.ClientID,
Company=tbclient.Company,
Fax=tbclient.Fax,
Mobile=tbclient.Mobile,
Name=tbclient.Name,
电话
});
返回cli;
}
控制器:
private StockDataClassesDataContext dc;
public IEnumerable<Client> GetClients()
{
dc = new StockDataClassesDataContext(ConString.DBConnection);
IEnumerable<Client> cli = (from tbclient in dc.tblClients
select new Client
{
Address = tbclient.Address,
ClientID = tbclient.ClientID,
Company = tbclient.Company,
Fax= tbclient.Fax,
Mobile = tbclient.Mobile,
Name = tbclient.Name,
Telephone = tbclient.Telephone
});
return cli;
}
public ActionResult Index()
{
JqGridClientRepository rep = new JqGridClientRepository();
IEnumerable<Client> clients = rep.GetClients();
return View(clients);
}
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<title>jqGrid for ASP.NET MVC - Demo</title>
<!-- The jQuery UI theme that will be used by the grid -->
<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/themes/redmond/jquery-ui.css" />
<!-- The Css UI theme extension of jqGrid -->
<link rel="stylesheet" type="text/css" href="../../Content/themes/ui.jqgrid.css" />
<!-- jQuery library is a prerequisite for jqGrid -->
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
<!-- language pack - MUST be included before the jqGrid javascript -->
<script type="text/javascript" src="../../Scripts/trirand/i18n/grid.locale-en.js"></script>
<!-- the jqGrid javascript runtime -->
<script type="text/javascript" src="../../Scripts/trirand/jquery.jqGrid.min.js"></script>
<h2>Index</h2>
</asp:Content>
public ActionResult Index()
{
JqGridClientRepository=新的JqGridClientRepository();
IEnumerable clients=rep.GetClients();
返回视图(客户端);
}
查看:
private StockDataClassesDataContext dc;
public IEnumerable<Client> GetClients()
{
dc = new StockDataClassesDataContext(ConString.DBConnection);
IEnumerable<Client> cli = (from tbclient in dc.tblClients
select new Client
{
Address = tbclient.Address,
ClientID = tbclient.ClientID,
Company = tbclient.Company,
Fax= tbclient.Fax,
Mobile = tbclient.Mobile,
Name = tbclient.Name,
Telephone = tbclient.Telephone
});
return cli;
}
public ActionResult Index()
{
JqGridClientRepository rep = new JqGridClientRepository();
IEnumerable<Client> clients = rep.GetClients();
return View(clients);
}
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<title>jqGrid for ASP.NET MVC - Demo</title>
<!-- The jQuery UI theme that will be used by the grid -->
<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/themes/redmond/jquery-ui.css" />
<!-- The Css UI theme extension of jqGrid -->
<link rel="stylesheet" type="text/css" href="../../Content/themes/ui.jqgrid.css" />
<!-- jQuery library is a prerequisite for jqGrid -->
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
<!-- language pack - MUST be included before the jqGrid javascript -->
<script type="text/javascript" src="../../Scripts/trirand/i18n/grid.locale-en.js"></script>
<!-- the jqGrid javascript runtime -->
<script type="text/javascript" src="../../Scripts/trirand/jquery.jqGrid.min.js"></script>
<h2>Index</h2>
</asp:Content>
jqGrid for ASP.NET MVC-演示
指数
JQGrid需要JSON。有一个非常不错的教程/扩展:
使用此扩展后,请配置JQGrid以下载数据