SpreadJS Documentation
sortColumn Method
The column index.
Set to true to sort as ascending.
Sorts the specified column in the specified order.
Syntax
var instance = new GcSpread.Sheets.RowFilterBase(range);
var value; // Type: boolean
value = instance.sortColumn(col, ascending);
function sortColumn( 
   col : number,
   ascending : boolean
) : boolean;

Parameters

col
The column index.
ascending
Set to true to sort as ascending.

Return Value

true if sorted successfully; otherwise, false.
Example
This example uses the sortColumn method.
//Create a custom condition.
function CustomFilter(){};
CustomFilter.prototype = {
    conditionType: "CustomFilter",
    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;
        }
    }
};

    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);

    //Set a row Filter.
    var rowFilter = new GcSpread.Sheets.HideRowFilter(new GcSpread.Sheets.Range(0, 0, 7, 1));
    activeSheet.rowFilter(rowFilter);
    rowFilter.addFilterItem(0, new CustomFilter());
    rowFilter.filter(0);
rowFilter.sortColumn(0, true);
See Also

Reference

RowFilterBase type

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.