剣道グリッドのフィルターにユーザー定義の検索値を設定したいとします。ユーザーがフィルタを開くと、その値が検索ボックスに表示されます。アドバイスをいただければ幸いです。剣道のグリッドでフィルターの定義済みの値を設定する
これは私が角度のJSを使用していることを除いてSet default filter for Kendo UI Gridに類似質問があり、私は、ユーザー定義の文字列のフィルタ値をしたい:
これは私が私のグリッドを構築する方法です。私は角度jsを使用してカスタム属性を持つdivを作成しています。最も注目すべき属性はsg-grid
(剣道グリッド自体)、sg-filterable
(このグリッドをフィルタリング可能にするにはtrueに設定)、sg-predefine-filter
(このグリッドのフィルタはそれは)開きます
マークアップここでデモするために簡略化され
<div sg-grid sg-data="api/grid/accounts" sg-columns="accountId,name,pricingFrequency,shortName,status" sg-filterable="true" sg-predefine-filter-value="true" </div>
スクリプティング()
angular.module('sgComponents').directive('sgGrid', [ return { restrict: 'AE', scope: { filterable: @sgFilterable, predefineFilterValue: @sgPredefineFilterValue}, template: '<div class="sg-grid">\ <div class="pager-bar">\ <div></div>\ // THE KENDO GRID </div>\ </div>', link: function(scope, element, attrs) { buildGrid(); function buildGrid() { var grid = element.find(':nth-child(2)'); // 2nd DIV IN THE TEMPLATE var gridOptions = buildGridOptions(scope, attrs, grid); grid.kendoGrid(gridOptions); // build the grid }; /** Builds the options for the grid */ function buildGridOptions(scope, attrs, grid) { if (scope.filterable === 'true') { opts.filterable = {}; opts.filterable.operators = {}; opts.filterable.operators.string = {} if (scope.predefineFilterValue === 'true') { // set a pre-defined value if true opts.filterable.operators.string = { eq: 'Is equal to', value:'Test' } } else { // just show the filter option opts.filterable.operators.string = { eq: 'Is equal to' } } } } } }; ]);
を
結果:0
ここコンソールログの画像です。ご覧のとおり、私の値は別のフィルターオプションとして追加されています。私はこれを望んでいない、私は値として入力ボックスにしたい!
ちょうどコメント:私は 'filter 'の' [] 'は必要ないと思います。少なくともドキュメントには含まれていません(http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-filter.field)。 – Andrew