A small test:
// Called by Directory Opus to initialize the script
function OnInit(initData) {
initData.name = "copy_item_test";
initData.version = "1.0";
initData.copyright = "(c) 2024 Cris";
// initData.url = "https://resource.dopus.com/c/buttons-scripts/16";
initData.desc = "";
initData.default_enable = true;
initData.min_version = "13.0";
}
// Called to add commands to Opus
function OnAddCommands(addCmdData) {
var cmd = addCmdData.AddCommand();
cmd.name = "CDI";
cmd.method = "OnCDI";
cmd.desc = "";
cmd.label = "CDI";
cmd.template = "";
cmd.hide = false;
cmd.icon = "script";
}
// Implement the CDI command
function OnCDI(scriptCmdData) {
var dlg = scriptCmdData.func.dlg;
dlg.template = 'dialog1';
dlg.Create();
var msg, row;
var list1 = dlg.control('listview1');
var list2 = dlg.control('listview2');
list1.EnableGroupView(true);
list2.EnableGroupView(true);
list1.AddGroup('test1', 0);
list1.AddGroup('test2', 1);
list2.AddGroup('test1', 0);
list2.AddGroup('test2', 1);
for (var i = 0; i < 5; i++) {
row = list1.getItemAt(list1.AddItem('Dummy ' + i, 0, 1)); // Add to test2 group
row.subitems(0) = i;
}
dlg.Show();
while (true) {
msg = dlg.GetMsg();
if (!msg.result) break;
if (msg.control == 'button1') {
for (var i = 0; i < list1.count; i++) {
row = list1.getItemAt(i);
DOpus.Output(row.name + ':' + row.group);
list2.AddItem(row); //doesn't work
}
DOpus.Output('list2:'+list2.count);
}
}
}
copy_item_test.opusscriptinstall (1.4 KB)
Whenever I try to copy the items from 'list1' to 'list2', nothing visible happens, 'list2' remains empty. However, the count
property for the Control
object indicates that the items were actually added.
As a side note, whenever I copy with groups disabled, it seems to work, but it only copies the first column, if there's more than one.