目前,我正在使用KendoGrid显示相当多的行,并进行分页。它适用于myData;但是,它返回的总行数与它查询的数据库表中的行数不同。
以下是我的控制器中的代码:
public ActionResult ExecuteTestRule(string ruleSql, string key, List<matchRuleParam> parameters)
{
if (Request.Url != null)
{
var dataSource = new MyDataSource();
List<DataAccess.DbParameter> dbParameters = null;
var generatedSql = dataSource.GenerateQuerySql(ruleSql, key, parameters, out dbParameters);
List<string> uwis = dataSource.ExecuteTestRule(generatedSql, dbParameters);
var myDataSet = new WellSetManager(Session.SessionID).Store(uwis);
var response = new Dictionary<string, object>();
response["wsid"] = myDataSet.Id;
return Json(response, JsonRequestBehavior.AllowGet);
}
return null;
}
以下是我的javascript文件中的代码:
function execTestRule(key) {
var parametersForSelectedRule = getParametersForSelectedRule();
$.ajax({
type: 'POST',
url: "ExecuteTestRule",
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({
ruleSql: PageState.SqlEditor.RuleSql.getValue(),
key: "'" + key + "'",
parameters: parametersForSelectedRule
}),
success: function (response) {
Grids.TestRuleResultsGrid.resultViewGrid("refresh",
{
keySetId: response.wsid
});
PageState.Selected.ChildKey = null;
PageState.TestRuleResult = true;
updateButtonStates();
},
error: function (jqXHR, textStatus, errorThrown) {
var errorObject = JSON.parse(jqXHR.responseText);
var errorMessage = errorObject.Message;
showErrorMessage(errorMessage, "Error");
}
});
}
其中,
Grids.TestRuleResultsGrid = $("#test-rule-results-grid").resultViewGrid({
viewId: "queryResults",
controllerUrl: getControllerUrl(navigation.controllers.resultView, ""),
enableSelection: false,
showChildGrids: false
以下是resultViewGrid的选项:
var gridOptions = {
dataSource: dataSource,
selectable: true,
sortable: true,
scrollable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
filterable: true,
columns: gridColumns,
resizable: true
};
以下是resultViewGrid的数据源:
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "{0}/ViewData".format(that.options.controllerUrl),
type: "get",
dataType: "json",
},
parameterMap: function(data) {
data.viewId = viewId;
data.joins = JSON.stringify(joins);
formatKendoParameterMapDates(data, function(fieldName) {
return dataSourceModel.fields[fieldName].type === "date";
});
return data;
}
},
schema: {
data: "mydata",
total: "total",
model: dataSourceModel
},
pageSize: childSettings.pageSize,
serverPaging: true,
serverSorting: true,
serverFiltering: true
});
执行COUNT SQL命令时,数据库中的行数为81658:
select COUNT(*) from TEST_AREA where AREA_TYPE= 'COUNTRY' and ACTIVE_IND = 'Y';
KendoGrid显示有79973行:
有没有人对KendoGrid为什么没有显示与Oracle数据库相同的行数有任何建议?
答案 0 :(得分:0)
结果是一个数据问题 - 该表有一些重复的键值,因此数据访问层内部的应用程序在KendoGrid中显示结果之前删除了这些重复项。以下是显示正确记录数的查询,这是网格显示的内容:
从中选择COUNT(*)(从TEST_AREA中选择DISTINCT KEY,其中AREA_TYPE ='COUNTRY'和ACTIVE_IND ='Y');