The built-in VBScript has unwanted side effects when clicking it:
-
The Size column is resized to fit the contents - it expands and shrinks to fit. I'd like it to stay the same size, (and only when applicable, expand to fit the larger amount of text.)
-
I have my Size column left-aligned by default. Clicking the button changes it to be right-aligned. I'd like to keep my left-alignment.
Is this possible? Thank you!
Here is the script contents:
Function OnClick(ByRef clickData)
sizeIdx = -1
sizeKbIdx = -1
sizeAutoIdx = -1
disksizeIdx = -1
disksizeKbIdx = -1
disksizeAutoIdx = -1
idx = 0
For Each colItem in clickData.func.sourcetab.format.columns
If (colItem.name = "size") Then sizeIdx = idx
If (colItem.name = "sizekb") Then sizeKbIdx = idx
If (colItem.name = "sizeauto") Then sizeAutoIdx = idx
If (colItem.name = "disksize") Then disksizeIdx = idx
If (colItem.name = "disksizekb") Then disksizeKbIdx = idx
If (colItem.name = "disksizeauto") Then disksizeAutoIdx = idx
idx = idx + 1
Next
Set cmd = clickData.func.command
If (sizeIdx <> -1 And sizeAutoIdx = -1 And sizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=size COLUMNSADD=sizeauto(" & sizeIdx & ")"
ElseIf (sizeIdx = -1 And sizeAutoIdx <> -1 And SizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=sizeauto COLUMNSADD=size(" & sizeAutoIdx & ")"
ElseIf (sizeIdx = -1 And sizeAutoIdx = -1 And SizeKbIdx <> -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=sizekb COLUMNSADD=size(" & sizeKbIdx & ")"
End If
If (disksizeIdx <> -1 And disksizeAutoIdx = -1 And disksizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=disksize COLUMNSADD=disksizeauto(" & disksizeIdx & ")"
ElseIf (disksizeIdx = -1 And disksizeAutoIdx <> -1 And disksizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=disksizeauto COLUMNSADD=disksize(" & disksizeAutoIdx & ")"
ElseIf (disksizeIdx = -1 And disksizeAutoIdx = -1 And disksizeKbIdx <> -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=disksizekb COLUMNSADD=disksize(" & disksizeKbIdx & ")"
End If
End Function
P.S. I did manage to get this other variation to function (I had to remove the very beginning "script" and ending "code".) Edit: I thought it halfway worked, but it does the exact same thing as the VBscript. Perhaps it would be easier to tweak this JScript version instead? Maybe not.
P.P.S. I wouldn't mind setting my default Size column to a static width, I suppose, if it would help... 80 would be optimal for me. Thanks!