Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

Highlight the first column of a table in Pure JavaScript

Background:

To highlight the first column of a table is to utilize the table method highlightFirstColumn to set an indicator to highlight the first column of the table when it is being created.

Steps to Complete:

1. Initialize SpreadJS and add a table from data source

2. Set highlightFirstColumn to True

Getting Started:

Step 1: Initialize SpreadJS and a table from data source

For this example, add a range table from the data source using SpreadJS’s addFromDataSource method and store it in the variable called table.

Use the following parameters to create the table:

  • Table Name: table

  • row:0

  • col:0,

  • data source: dataArray

  • style: dark1

The final script tag should appear as so:

  <script></script>

After this step, the table should appear like this:

Step 2: Set highlightFirstColumn to True

Underneath where we have added a table from the data source, set the highlightFirstColumn method to True to indicate to highlight the first column.

// Add table from data source
      var table = sheet.tables.addFromDataSource(
        "table",
        0,
        0,
        dataArray,
        GC.Spread.Sheets.Tables.TableThemes.dark1
      );
// Indicate to highlight the first column
       table.highlightFirstColumn(true);

After this step, the table will now have the first column highlighted like so: