【发布时间】:2014-12-15 14:30:19
【问题描述】:
我有一个输入文本框、一个按钮和一个剑道网格。剑道网格的数据源是 Rest webservice url。我的 Rest web 服务需要一个输入参数,在此基础上它发送适当的 json 数据。我的要求是,每当我单击按钮时,它都会从输入框中获取数据,将其作为输入参数附加到 Rest url,从 Web 服务中获取并显示相应的数据。如果我更改输入文本框中的值并再次单击按钮,则应该使用从 Web 服务返回的新数据集刷新剑道网格。下面是我的代码。 HTML:
<div ng-app="myApp">
<div ng-controller="myCtrl">
<div>
<form>
Enter Param
<div>
<input type="text" ng-model="param">
</div>
<button type="submit" ng-click="submitParam()">Submit</button>
</form>
</div>
<div id="grid" kendo-grid k-options="kendoGrid"></div>
</div>
</div>
控制器:
var myApp = angular.module('myApp',[]);
myApp.controller('myCtrl', function ($scope, myService) {
$scope.param = "";
$scope.kendoGrid = myService.getKGrid();
$scope.submitParam = function(){
**//here param should be appended in the Rest URL and kendo grid data should change as per the** new URL.
}
});
服务:
myApp.service('myService', function () {
this.getKGrid = function () {
var kGrid = {
dataSource: {
transport: {
read: {
url: MyRestURL/param,**//Here the param will be appended**
dataType: "json"
}
},
},
columns: [{
field: "Col1",
title: "Col1"
},
{
field: "Col2",
title: "Col2"
}
]
};
return kGrid;
};
});
【问题讨论】:
标签: kendo-grid