GP SoftwareTwitter
Opus FAQsManualCommandsObjects

DO12 - Set COLUMNSADD fails

First, let me thank you Leo for providing the toggle button to switch the fill-columns to auto and back to folder default.
People can find it here, in the tutorial thread: Tutorial video: Column resizing & folder formats

The toggle button does not work for me. To be more precise, it's the command in the subject within the button that fails, and it does so whenever on of my script columns is involved.

This may be caused by using ":" in the script/column name, tested other peoples columns and it's ok with those it seems. The command fails if a single column or multiple column names are passed (like in your button).

Set COLUMNSADD=scp:Column.Generic: ModifiedWithin/ModifiedWithin-Graph(!,a,0)

Not sure if this is a DO12 only issue, but I guess I would have noticed my script columns not working in conjunction with Set COLUMNSADD/REMOVE, but I won't bet on it! o)

Thanks again! o)

If there is a space in the column name, you'll need to quote the arguments.

I'm not sure if colons are allowed in column names or not. It's probably not a good idea, but it may work, I don't know.

Aha, so the error is on my side. Very good, I prefer that! o) I was kinda blinded by the colon, overlooking the more obvious space issue.
Indeed, the d-quotes made it work! I tweaked your button a little so it always uses quotes for the Set COLUMNADD command.

v0.1 - Leos initial post here: Tutorial video: Column resizing & folder formats
v0.2 - fixed to work with spaces in column names (affects script columns)

function OnClick(clickData){
	var colParams = "";
	for(var e = new Enumerator(clickData.func.sourcetab.format.columns); !e.atEnd(); e.moveNext()){
		var col = e.item();
		if (!col.Autosize || col.Max != 0){
			if (colParams) colParams += ",";
			colParams += col.Name;
			colParams += "(!,a,0)"; // Keep position. Auto-size. No maximum.
		}
	}
	var cmd = "Set FORMAT=!folder";
	if (colParams) cmd = 'Set COLUMNSADD="'+colParams+'"';
	clickData.func.command.RunCommand(cmd);
}

Thank you for the quick solution! o)

My error as well. :slight_smile: I've updated my post in the other thread to include your improvements.

Hello,

thank's for this great script. One Question please. Is there a way to add "@nodeselect".
Im not very good to write scripts can you please help me.

apologize my bad english

May Thanks

Greetings Lezgus

Here you go (I just added the line containing "..deselect = false;" in the bottom):

v0.1 - Leos initial post here: Tutorial video: Column resizing & folder formats
v0.2 - fixed to work with spaces in column names (affects script columns)
v0.3 - no deselecting of items

function OnClick(clickData){
   var colParams = "";
   
   for(var e = new Enumerator(clickData.func.sourcetab.format.columns); !e.atEnd(); e.moveNext()){
      var col = e.item();
      if (!col.Autosize || col.Max != 0){
         if (colParams) colParams += ",";
         colParams += col.Name;
         colParams += "(!,a,0)"; // Keep position. Auto-size. No maximum.
      }
   }
   var cmd = "Set FORMAT=!folder";
   if (colParams) cmd = 'Set COLUMNSADD="'+colParams+'"';
   clickData.func.command.deselect = false;
   clickData.func.command.RunCommand(cmd);
}

Great!

It works, many thanks

Greetings Lezgus