SpreadJS Documentation > Sample Code > Sample Code for Sorting > Sorting Row Ranges with Sort Conditions |
You can specify multiple sort conditions when sorting.
This example sorts rows using multiple sort keys.
JavaScript |
Copy Code
|
---|---|
$(document).ready(function () { ///Execute sorting which targets all rows based on the created sorting conditions. |
This example sorts rows using multiple sort keys.
JavaScript |
Copy Code
|
---|---|
$(document).ready(function () { $("#ss").wijspread(); var activeSheet = $("#ss").wijspread("spread").getActiveSheet(); activeSheet.setRowCount(6); activeSheet.setValue(0, 0, 10); activeSheet.setValue(1, 0, 100); activeSheet.setValue(2, 0, 100); activeSheet.setValue(3, 0, 10); activeSheet.setValue(4, 0, 5); activeSheet.setValue(5, 0, 10); activeSheet.setValue(0, 1, 10); activeSheet.setValue(1, 1, 40); activeSheet.setValue(2, 1, 10); activeSheet.setValue(3, 1, 20); activeSheet.setValue(4, 1, 10); activeSheet.setValue(5, 1, 40); $("#button1").click(function(){ //Create a SortInfo object where 1st Key:Column1/2nd Key:Column2. var sortInfo = [ {index:0, ascending:true}, {index:1, ascending:true}]; ///Execute sorting which targets all rows based on the created sorting conditions. $("#ss").wijspread("spread").getActiveSheet().sortRange(0, 0, 6, 2, true, sortInfo); }); }); |