How Can I create a custom binding for a SpreadJs datagrid to align a column?

Posted by: lsanchez on 19 October 2017, 9:21 am EST

    • Post Options:
    • Link

    Posted 19 October 2017, 9:21 am EST

    When I am creating a new column for my SPreadJs grid, I don’t see any property to align my columns. For example:

    var nameColInfo = { name: "Name", displayName: "Name", size: "150", resizable: true };
    

    I would like to add a new custom binding to my grid called align. Something like this

    var nameColInfo = { name: "Name", displayName: "Name", size: "150", resizable: true, **[b]align: right[/b]** };
    

    I don’t know if this is already done by someone else. If not I will appreciate your help. I don’t want to loop over my datagrid, row by row to align every cell that I need. Also I don’t want to create a custom column.

  • Posted 25 October 2017, 6:17 am EST

    Hello,

    Please have a look at the code to set horizonal and vertical alignment of particular column:-

    // setting horizontal alignment of Col B to left
                   // setting horizontal alignment of Col B to left
                sheet.getRange(-1, 1, -1, 1, GC.Spread.Sheets.SheetArea.viewport).hAlign(GC.Spread.Sheets.HorizontalAlign.left);
                // setting vertical alignment of Col B to top
                sheet.getRange(-1, 1, -1, 1, GC.Spread.Sheets.SheetArea.viewport).vAlign(GC.Spread.Sheets.VerticalAlign.top);
    
    
    

    Hope it helps.

    Thanks,

    Reeva

Need extra support?

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

Learn More

Forum Channels