Script to change Column width on a canvas table

4.08K viewsScriptingscripting
0

Hi Everyone, I’m trying to script column width formatting to a table view on a canvas. Here’s what I tried but it is causing a “Can’t get property ‘model’ on null object”. What am I missing?

thanks for looking!

// Access the current model
def model = matrix.model

// Access the specific canvas
def canvas = model.getCanvas("Month Input")

// Access the table view on the canvas
def tableView = canvas.getTableView("Strat Plan Month Ref - Table View 3")

// Set the width of a specific column in the table view
tableView.setColumnWidth("Month", 100) // Width in pixels
Tahir Answered question
0

Hi jeffc,

Sau provided a great example of how to solve this problem. If you’d like to change the column width for all items (which is probably the usual case), you can also use the following simple script. First, create a Matrix2 and place it on Canvas1. Then, use this script to change the column width of all items in category C.

Or if you like to change column width only for one item (C1) you can use this one:

Please note that the column width value is in pixels. Depending on the PPI of your screen, you may need to experiment to find the best value that meets your needs.

Tahir

jeffc Posted new comment

thank you Tahir. This solution worked!

0

Hi jeffc,

Try this A-script to solve your problem:
*

*
Good luck

jeffc Posted new comment

thank you S A U! I keep learning new ways to approach the work I’m doing