Spread.Sheets
addFilterItem メソッド
列インデックス。
フィルタリングする条件。
指定したフィルタを行フィルタに追加します。
シンタックス
Javascript (Usage) 
var instance = new GC.Spread.Sheets.Filter.RowFilterBase(range);
var value; // Type: any
value = instance.addFilterItem(col, condition);
Javascript (Specification) 
function addFilterItem( 
   col : number,
   condition : Condition
) : any;

パラメータ

col
列インデックス。
condition
フィルタリングする条件。
使用例
次のサンプルコードは、カスタムフィルタを作成します。次のサンプルコードは、カスタムフィルタを追加します。
//Create a custom condition.
        function CustomFilter(){
            GC.Spread.Sheets.ConditionalFormatting.Condition.apply(this, arguments);
            //this.conditionType("CustomFilter");
        };
        CustomFilter.prototype = new GC.Spread.Sheets.ConditionalFormatting.Condition();
        CustomFilter.prototype.evaluate = function (evaluator, row, col) {
            var value = evaluator.getValue(row, col);

            if (value !== null && value >= 10 && value <= 50) {
                //Return True only when the following conditions are satisfied.
                // (1)Values are entered.
                // (2)Values are not lower than 10.
                // (3)Values are not greater than 50.
                return true;
            } else {
                return false;
            }
        };

        $(function () {
            var workbook = new GC.Spread.Sheets.Workbook($("#ss")[0]);
            var activeSheet = workbook.getActiveSheet();
            activeSheet.setValue(0, 0, 10);
            activeSheet.setValue(1, 0, 100);
            activeSheet.setValue(2, 0, 50);
            activeSheet.setValue(3, 0, 40);
            activeSheet.setValue(4, 0, 80);
            activeSheet.setValue(5, 0, 1);
            activeSheet.setValue(6, 0, 65);
            activeSheet.setValue(7, 0, 20);
            activeSheet.setValue(8, 0, 30);
            activeSheet.setValue(9, 0, 35);

            $("#button1").click(function(){
                //Set a row Filter.
                var rowFilter = new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(0, 0, 7, 1));
                activeSheet.rowFilter(rowFilter);
                rowFilter.addFilterItem(0, new CustomFilter());
                rowFilter.filter(0);
            });
        });
//Create a custom condition.
        function CustomFilter(){
            GC.Spread.Sheets.ConditionalFormatting.Condition.apply(this, arguments);
            //this.conditionType("CustomFilter");
        };
        CustomFilter.prototype = new GC.Spread.Sheets.ConditionalFormatting.Condition();
        CustomFilter.prototype.evaluate = function (evaluator, row, col) {
            var value = evaluator.getValue(row, col);

            if (value !== null && value >= 10 && value <= 50) {
                //Return True only when the following conditions are satisfied.
                // (1)Values are entered.
                // (2)Values are not lower than 10.
                // (3)Values are not greater than 50.
                return true;
            } else {
                return false;
            }
        };

        $(function () {
            var workbook = new GC.Spread.Sheets.Workbook($("#ss")[0]);
            var activeSheet = workbook.getActiveSheet();
            activeSheet.setValue(0, 0, 10);
            activeSheet.setValue(1, 0, 100);
            activeSheet.setValue(2, 0, 50);
            activeSheet.setValue(3, 0, 40);
            activeSheet.setValue(4, 0, 80);
            activeSheet.setValue(5, 0, 1);
            activeSheet.setValue(6, 0, 65);
            activeSheet.setValue(7, 0, 20);
            activeSheet.setValue(8, 0, 30);
            activeSheet.setValue(9, 0, 35);

            $("#button1").click(function(){
                //Set a row Filter.
                var rowFilter = new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(0, 0, 7, 1));
                activeSheet.rowFilter(rowFilter);
                rowFilter.addFilterItem(0, new CustomFilter());
                rowFilter.filter(0);
                rowFilter.filterButtonVisible(0, true);
                alert(rowFilter.filterButtonVisible(0));
            });
        });

関連トピック

参照

RowFilterBase タイプ

 

 


© 2016-2018, GrapeCity inc. All rights reserved.