Jquery 在使用Wijmo和nockout Javascript的ASP.NET web应用程序中,数据不会显示在网格视图中

Jquery 在使用Wijmo和nockout Javascript的ASP.NET web应用程序中,数据不会显示在网格视图中,jquery,asp.net-mvc-4,razor,knockout.js,wijmo,Jquery,Asp.net Mvc 4,Razor,Knockout.js,Wijmo,我正在尝试查看一个ASP.NET页面,该页面将在网格中显示客户操作信息。网格将包含操作ID、客户ID、案例ID、操作日期/时间、操作类型、操作人和序列号选项卡 开发工作是在ASP.NET 4.5中使用knockout.js和Bootstrap完成的,它是使用7层体系结构开发的。这些层是公共层、核心层、DAL(数据访问层)、DTO(数据传输对象)、管理器、存储库和Web 到目前为止,我已经创建了核心类、工厂类、存储库接口、DTO类、表单类、管理器类和接口、存储库类和视图文件 视图文件中的代码如下所

我正在尝试查看一个ASP.NET页面,该页面将在网格中显示客户操作信息。网格将包含操作ID、客户ID、案例ID、操作日期/时间、操作类型、操作人和序列号选项卡

开发工作是在ASP.NET 4.5中使用knockout.js和Bootstrap完成的,它是使用7层体系结构开发的。这些层是公共层、核心层、DAL(数据访问层)、DTO(数据传输对象)、管理器、存储库和Web

到目前为止,我已经创建了核心类、工厂类、存储库接口、DTO类、表单类、管理器类和接口、存储库类和视图文件

视图文件中的代码如下所示:

<!-- jQuery -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0 /jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<!-- Wijmo CSS and script -->
<link type="text/css" href="http://cdn.wijmo.com/themes/metro/jquery-wijmo.css" rel="stylesheet" title="metro-jqueryui" />
<link type="text/css" href="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.2.0.min.css" rel="stylesheet" />
<script type="text/javascript" src="http://cdn.wijmo.com/jquery.wijmo-open.all.2.2.0.min.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.2.0.min.js"></script>
<!-- KnockoutJS for MVVM-->
<script type="text/javascript" src="http://cdn.wijmo.com/external/knockout-2.3.0.js"></script>


//创建视图模型
var CustomerActionsviewModel={
页面大小:ko.可观察(10),
pageIndex:ko.可观察(0),
sortCommand:ko.可观察(“ActionID asc”),
数据行:ko.observearray([]),
totalRows:ko.可观测(0),
排序:函数(e,数据){
CustomerActionsviewModel.sortCommand(data.sortCommand);
},
第页:功能(e,数据){
CustomerActionsviewModel.pageIndex(data.newPageIndex);
},
加载:函数(){
$.ajax({
url:“/CustomerAction/”,
数据类型:“jsonp”,
jsonp:“$callback”,
数据:{
$format:“json”,
$INLINECUNT:“所有页面”,
$select:“ActionID、CustomerID、CaseID、ActionDateTime、ActionType、ActionBy、SlNo”,
$orderby:CustomerActionsviewModel.sortCommand(),
$top:CustomerActionsviewModel.pageSize(),
$skip:CustomerActionsviewModel.pageIndex()*CustomerActionsviewModel.pageSize(),
“分页[pageIndex]”:CustomerActionsviewModel.pageIndex(),
“分页[pageSize]”:CustomerActionsviewModel.pageSize()
},
成功:功能(结果){
var数据=结果d.结果;
var-arr=[];
$。每个(数据、功能(i){
arr.push(新客户操作(数据[i]);
});
CustomerActionsviewModel.totalRows(结果d.\u计数);
CustomerActionsviewModel.dataRows(arr);
}
});
}
};
//网格行的类构造函数。返回可观察的属性。
var customerAction=函数(数据){
返回{
ActionID:ko.可观察(data.ActionID),
CustomerID:ko.可观察(data.CustomerID),
CaseID:ko.可观察(data.CaseID),
ActionDateTime:ko.可观察(data.ActionDateTime),
ActionType:ko.可观察(data.ActionType),
ActionBy:ko.可观察(data.ActionBy),
SlNo:ko.可观察(data.SlNo)
};
};
显示:
5.
10
20
//绑定ViewModel和事件处理程序
$(文档).ready(函数(){
ko.应用绑定(CustomerActionsviewModel);
CustomerActionsviewModel.load();
CustomerActionsviewModel.sortCommand.subscribe(函数(newValue){
CustomerActionsviewModel.load();
});
CustomerActionsviewModel.pageIndex.subscribe(函数(newValue){
CustomerActionsviewModel.load();
});
CustomerActionsviewModel.pageSize.subscribe(函数(newValue)){
CustomerActionsviewModel.load();
$(“:wijmo wijdropdown”).wijdropdown(“刷新”);
});
});

问题是,数据是从数据库加载的,但加载的数据不会被查看。有人能告诉我问题出在哪里吗???

您有错误吗?可能是在客户端对客户端,您得到一个错误500。你检查过网络浏览器的请求日志了吗?@Damien没有,我没有收到任何错误。我用来查看此页面的web浏览器是Internet Explorer 8。
<script>
//Create ViewModel
var CustomerActionsviewModel = {
pageSize: ko.observable(10),
pageIndex: ko.observable(0),
sortCommand: ko.observable("ActionID asc"),
dataRows: ko.observableArray([]),
totalRows: ko.observable(0),
sorted: function (e, data) {
    CustomerActionsviewModel.sortCommand(data.sortCommand);
},
paged: function (e, data) {
    CustomerActionsviewModel.pageIndex(data.newPageIndex);
},
load: function () {
    $.ajax({
        url: '/CustomerAction/',
        dataType: "jsonp",
        jsonp: "$callback",
        data: {
            $format: "json",
            $inlinecount: "allpages",
            $select: "ActionID,CustomerID,CaseID,ActionDateTime,ActionType,ActionBy,SlNo",
            $orderby: CustomerActionsviewModel.sortCommand(),
            $top: CustomerActionsviewModel.pageSize(),
            $skip: CustomerActionsviewModel.pageIndex() * CustomerActionsviewModel.pageSize(),
            "paging[pageIndex]": CustomerActionsviewModel.pageIndex(),
            "paging[pageSize]": CustomerActionsviewModel.pageSize()
        },
        success: function (result) {
            var data = result.d.results;
            var arr = [];

            $.each(data, function (i) {
                arr.push(new customerAction(data[i]));
            });
            CustomerActionsviewModel.totalRows(result.d.__count);
            CustomerActionsviewModel.dataRows(arr);
        }
      });
   }

};

 //Class constructor for grid row. Returns observable properties.
 var customerAction = function (data) {
 return {
    ActionID: ko.observable(data.ActionID),
    CustomerID: ko.observable(data.CustomerID),
    CaseID: ko.observable(data.CaseID),
    ActionDateTime: ko.observable(data.ActionDateTime),
    ActionType: ko.observable(data.ActionType),
    ActionBy: ko.observable(data.ActionBy),
    SlNo: ko.observable(data.SlNo)
    };
};
</script>

<div class="toolbar">
<label>Display: </label>
<select data-bind="value: pageSize, wijdropdown: {}">
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
</select>
</div>
<table id="dataGrid" data-bind="
wijgrid: {
data: dataRows,
pageSize: pageSize,
pageIndex: pageIndex,
totalRows: totalRows,
allowPaging: true,
allowSorting: true,
sorted: sorted,
pageIndexChanged: paged,
columns: [
{ sortDirection: 'ascending', dataType: 'number', dataFormatString: 'n0', headerText: 'Action ID', width: 60 },
{ dataType: 'number', dataFormatString: 'n0', headerText: 'Customer ID', width: 60},
{ dataType: 'number', dataFormatString: 'n0', headerText: 'Case ID', width: 60},
{ headerText: 'Action Date/Time', width: 100},
{ headerText: 'Action Type', width: 100 },
{ headerText: 'Action By', width: 100 },
{ dataType: 'number', dataFormatString: 'n0', headerText: 'Serial No', width: 60}]
}">
</table>

<script>
//Bind ViewModel and Event Handlers
$(document).ready(function () {
ko.applyBindings(CustomerActionsviewModel);
CustomerActionsviewModel.load();
CustomerActionsviewModel.sortCommand.subscribe(function (newValue) {
    CustomerActionsviewModel.load();
});
CustomerActionsviewModel.pageIndex.subscribe(function (newValue) {
    CustomerActionsviewModel.load();
});
CustomerActionsviewModel.pageSize.subscribe(function (newValue) {
    CustomerActionsviewModel.load();
$(":wijmo-wijdropdown").wijdropdown("refresh");
});
});
</script>