【问题标题】:Bind Kendo Grid datasource(RestURL) with dynamic input param使用动态输入参数绑定 Kendo Grid 数据源(RestURL)
【发布时间】: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


    【解决方案1】:

    我可以通过使用 Grid 数据源的 grid.dataSource.transport.options.read.url 属性动态更改数据源 URL 来解决问题。 参考链接:Kendo UI Dynamically Change Datasource String (XML)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-27
      • 1970-01-01
      • 2013-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多