SpreadJS 13
SpreadJS Documentation / Sample Code / Sample Code for Data Binding / Binding to Columns
In This Topic
    Binding to Columns
    In This Topic

    You can bind to specific columns.

    Column binding

    Using Code

    This example binds the columns.

    JavaScript
    Copy Code
    window.onload = function()
    {
       var spread =
       new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
       var activeSheet = spread.getActiveSheet();
    
       // Deactivate automatic column generation while binding.
       activeSheet.autoGenerateColumns = false;
    
       // Create a data table manually.
       var sampleTable =
       [
        {"ID":10, "Text":"Text-10", "Check":true},
        {"ID":20, "Text":"Text-20", "Check":false},
        {"ID":30, "Text":"Text-30", "Check":false},
        {"ID":40, "Text":"Text-40", "Check":true},
        {"ID":50, "Text":"Text-50", "Check":true}
       ];
    
       // Bind the data table
       activeSheet.setDataSource(sampleTable);
    
       // Bind only specific fields.
       activeSheet.bindColumn(0, "Check");
       activeSheet.bindColumn(1, "ID");
       activeSheet.setColumnCount(2);
    }
    
    See Also

    Developer's Guide