我已经在按钮上写了一个onClick
,用于从服务器获取数据,但是并没有带我去使用服务器端编写的GetMPFilter
函数
$scope.GetFilter = function () {
var strZone = $('#SAPExecutive_R4GState').val();
var strUtility = $('#ddlUtility').val();
$scope.dtColumns = [
DTColumnBuilder.newColumn(null, '').renderWith(function (data, type, full) {
return '<input type="checkbox" class="check" data-object-id="' + full.objectid + '">'
}),
DTColumnBuilder.newColumn("MAINTENANCEZONENAME", "MAINTENANCEZONENAME"),
DTColumnBuilder.newColumn("MAINTENANCEZONECODE", "MAINTENANCEZONECODE")
]
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
method: "POST",
url: AppConfig.PrefixURL + "/App/GetMPFilter",
dataType: 'json',
data: JSON.stringify({ strZone: strZone, strUtility: strUtility }),
headers: { "Content-Type": "application/json" }
})
.withPaginationType('full_numbers')
.withDisplayLength(10);
}
});
Server code
[HttpPost]
public JsonResult GetMPFilter(string strZone, string strUtility)
{
DataTable dt = new DataTable();
Filters ObjFilter = new Filters();
dt = ObjFilter.GetMPFromState(strZone, strUtility);
var MpList = (from DataRow dr in dt.Rows
select new
{
//Action = "",
MZONENAME = Convert.ToString(dr["MAINTENANCEZONENAME"]),
MZONECODE = Convert.ToString(dr["MAINTENANCEZONECODE"]),
}).ToList();
return Json(MpList, JsonRequestBehavior.AllowGet);
}
<button class="btn btn-default customBtn" ng-click="GetFilter();"><i class="fa fa-filter" aria-hidden="true"></i> Filter</button>
请提出我错了的地方
答案 0 :(得分:0)
请使用我发布的这些更改。希望这能解决您的问题。谢谢。
$scope.GetFilter = function () {
var strZone = $('#SAPExecutive_R4GState').val();
var strUtility = $('#ddlUtility').val();
$scope.dtColumns = [
DTColumnBuilder.newColumn(null, '').renderWith(function (data, type, full) {
return '<input type="checkbox" class="check" data-object-id="' + full.objectid + '">'
}),
DTColumnBuilder.newColumn("MAINTENANCEZONENAME", "MAINTENANCEZONENAME"),
DTColumnBuilder.newColumn("MAINTENANCEZONECODE", "MAINTENANCEZONECODE")
]
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
method: "POST",
url: AppConfig.PrefixURL + "/App/GetMPFilter",
dataType: 'json',
data: "{strZone:'" + strZone + "',strUtility:'" + strUtility + "'}",
headers: { "Content-Type": "application/json; charset=utf-8" }
})
.withPaginationType('full_numbers')
.withDisplayLength(10);
}
});
这是按钮单击的简单示例:
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
{{msg}}
<a ng-href='#here' ng-click='go()' >click me</a>
<div style='height:1000px'>
<a id='here'></a>
</div>
<h1>here</h1>
</body>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.go = function() {
$scope.msg = 'clicked';
}
});