google spreadsheet sidebar setWidth not working
Asked Answered
U

2

24

Anybody else having trouble with the setWidth function? The example here is "300", but if you change the number, the sidebar is the same width. I've tried a few times on a clean spreadsheet.

https://developers.google.com/apps-script/guides/dialogs#custom_sidebars

Unbeknown answered 5/3, 2014 at 4:48 Comment(1)
lol, i thought i was going crazyImpend
H
34

Google Scripts now ignore the setWidth() method, and the sidebar width is now fixed at 300px. From the release notes:

In Google Docs and Forms, sidebars now ignore the setWidth() method; they cannot be changed from the default width of 300px. This change was applied to the new version of Sheets in the previous week's release.

SetWidth Deprecated

Homovec answered 5/3, 2014 at 5:22 Comment(2)
For those who want the exact link to the release developers.google.com/apps-script/releases/…Billiards
@gingacodemonkey: updated link to the release notes from Feb 2014 (they changed the capitalization of the anchor)Doronicum
B
28

I created a little workaround for this (although this is only useful if this sheet is something you're using for yourself or internally in a company, but not for deployment to other users)...

I created a bookmark containing the following JS, and run it form my favourites bar whenever I want to widen the sidebar (also, any sidebar opened thereafter in that session will open at the new width):

javascript:void(window.top.document.getElementsByClassName("script-application-sidebar")[0].style.width='500px')

To create the bookmark (this example is for Chrome), right click on your favourites bar, click 'Add Page', and paste the above JS into the URL field. Name it whatever you want, e.g. 'Widen Sidebar'. Just click that whenever the sidebar is visible in your Google Sheet.

Bochum answered 9/12, 2014 at 16:14 Comment(1)
also you can do it with TamperMonkey script: GM_addStyle('div.script-application-sidebar { width: 700px; }'); make sure to add this in header(instead of + is @): // +match docs.google.com/spreadsheets/d* // +grant GM_addStyleMagee

© 2022 - 2024 — McMap. All rights reserved.