CustomBinding Source

Posted by: hghanta on 15 February 2018, 1:57 am EST

    • Post Options:
    • Link

    Posted 15 February 2018, 1:57 am EST

    I need flexibility to specify my own binding source instead of the Default CellBindingSource. Is it possible in spread-sheets.

    Thanks,

    Sri Harsha

  • Posted 15 February 2018, 11:14 am EST

    Hello,

    Spread.Sheets supports three type of bindings sheet level binding, cell level binding and table level binding. Here is the code to perform sheet level binding:

    
    var datasource = [
       { name: 'Alice', age: 27, birthday: '1985/08/31', position: 'PM' }
    ];
    // bindColumn one by one 
    var nameColInfo = { name: 'name', displayName: 'Display Name', size: 70 };
    var ageColInfo = { name: 'age', displayName: 'Age', size: 40, resizable: false };
    var birthdayColInfo = { name: 'birthday', displayName: 'Birthday', formatter: 'd/M/yy', size: 120 };
    var positionColInfo = { name: 'position', displayName: 'Position', size: 50, visible: false };
    sheet.autoGenerateColumns = false;
    sheet.setDataSource(datasource);
    sheet.bindColumn(0, nameColInfo);
    sheet.bindColumn(1, birthdayColInfo);
    sheet.bindColumn(2, ageColInfo);
    sheet.bindColumn(3, positionColInfo);
    
    // or use bindColumns to bind all custom columns
    var colInfos = [
       { name: 'position', displayName: 'Position', size: 50, visible: false },
       { name: 'name', displayName: 'Display Name', size: 70 },
       { name: 'birthday', displayName: 'Birthday', formatter: 'd/M/yy', size: 120 },
       { name: 'age', displayName: 'Age', size: 40, resizable: false },
    ];
    sheet.autoGenerateColumns = false;
    sheet.setDataSource(datasource);
    sheet.bindColumns(colInfos);
    
    

    Read more about it here:

    http://help.grapecity.com/spread/SpreadSheets11/webframe.html#SpreadJS~GC.Spread.Sheets.Worksheet~setDataSource.html

    http://help.grapecity.com/spread/SpreadSheets11/webframe.html#scbindtable.html

    Thanks,

    Deepak Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels