如何在Angular-Kendo下拉列表中应用角度过滤器?

时间:2015-01-14 06:25:24

标签: angularjs kendo-ui angular-filters kendo-dropdown

以下是我需要绑定到两个kendo下拉列表的数据源。一个用于程序,另一个用于IForm。我需要在下拉列表中完成过滤。

$scope.programIFormList = new kendo.data.DataSource({
        data: [
                    {
                        Name: "Program1",
                        IsProgram: "true",
                        ProgramId: 1,
                        Status: 0,
                        PatientId: 1,
                        StartDate:"",
                        EndDate:""
                    },
                    {
                        Name: "Program2",
                        IsProgram: "false",
                        ProgramId: 2,
                        Status: 0,
                        PatientId: 1,
                        StartDate:"",
                        EndDate:""
                    }
                ]
    }); 

下面是html代码:

 <div class="col-lg-2 col-md-4 col-sm-4 col-xs-4">
                    <select id="patient" kendo-drop-down-list k-data-text-field="'Name'" k-data-value-field="'PatientId'"  k-data-source="patientList" >                      
                    </select>
                </div>

                <div class="col-lg-2 col-md-4 col-sm-4 col-xs-4">
                    <select kendo-drop-down-list k-data-text-field="'Name'" k-data-value-field="'ProgramId'" k-data-source="programIFormList | filter:{IsProgram: true}" k-cascade-from="'patient'">
                    </select>
                </div>
                <div class="col-lg-2 col-md-4 col-sm-4 col-xs-4">
                    <select kendo-drop-down-list k-data-text-field="'Name'" k-data-value-field="'ProgramId'" k-data-source="programIFormList | filter:{IsProgram: false}"  k-cascade-from="'patient'">
                    </select>
                </div>

在这里,我正在尝试应用角度滤波器。但它不起作用。如何使用Kendo Angular实现这一目标?

1 个答案:

答案 0 :(得分:0)

您可以使用此方法

angular.module("MyApp", [ "kendo.directives" ])
      .controller("FilterController", function($scope){


          $scope.programIFormList = new kendo.data.DataSource({
              data: [
                          {
                              Name: "Program3",
                              IsProgram: "true",
                              ProgramId: 1,
                              Status: 0,
                              PatientId: 1,
                              StartDate: "",
                              EndDate: ""
                          },
                          {
                              Name: "Program1",
                              IsProgram: "false",
                              ProgramId: 2,
                              Status: 0,
                              PatientId: 1,
                              StartDate: "",
                              EndDate: ""
                          }
              ],
              filter: [
                { field: "IsProgram", operator: "eq", value: "true" }

              ]
          });
      });