1
nopcommerce
の得意先テーブルのデータを管理ページに表示したいとします。
私はplugin
を書いていましたが、コントローラにデータを受け取りましたが、私は問題があり、私にerror happened
というメッセージが表示されています。ここ
は私controller
コードです:nopcommerceで得意先テーブルのデータにアクセスする方法
public class UserDetailsController : BasePluginController
{
private ICustomerService _UserDetail;
public UserDetailsController(ICustomerService UserDetail)
{
_UserDetail = UserDetail;
}
public ActionResult Manage()
{
return View();
}
[HttpPost]
public ActionResult GetUsers(DataSourceRequest userDetail)
{
var details = _UserDetail.GetAllCustomers();
var gridModel = new DataSourceResult
{
Data = details,
Total = details.Count
};
return Json(gridModel);
}
}
そして、これが私のview
コードです:
@{
Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<script>
$(document).ready(function() {
$("#user-details").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "@Html.Raw(Url.Action("GetUsers", "UserDetails"))",
type: "POST",
dataType: "json",
},
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
}
},
requestEnd: function(e) {
if (e.type == "update") {
this.read();
}
},
error: function(e) {
display_kendoui_grid_error(e);
// Cancel the changes
this.cancelChanges();
},
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
pageable: {
refresh: true,
numeric: false,
previousNext: false,
info:false
},
editable: {
confirmation: true,
mode: "inline"
},
scrollable: false,
columns: [
{
field: "Email",
title: "User Name",
width: 200
},
{
command: [
{
name: "edit",
text: "@T("Admin.Common.Edit")"
}, {
name: "destroy",
text: "@T("Admin.Common.Delete")"
}
],
width: 200
}
]
});
});
</script>
<div id="user-details"></div>
誰も私を助けることができますか?
が何であるかをDataListコントロール、私はあなたが詳細を意味する任意のdataList.didていなかったし、別の問題は、あなたが新しいUserDetailを返すどのように私はそれを行うカントであり、かつ私はこのコードには問題があると思います。 – Mojtaba
はい、それは私の間違いでした、私は更新しました。何か問題がありますか? –
これはサンプルコードなので、このようにすることができます。 –