I am trying to group items in a listview in a dialog.
Populating the listiview with ungrouped items does work flawlessly.
When trying to add groups to the listview and assigning items to these groups, the listview is empty.
The example i found is this one https://resource.dopus.com/t/listview-groups/35842/2
The groups are generated first, then EnableGroupView(true);
gets called. The example works for me, however i was not able to get my code to show the grouped items and could need some help
function OnClick(clickData)
{
oneLoop(clickData);
twoLoops(clickData);
}
function oneLoop(clickData)
{
var dlg = DOpus.Dlg;
dlg.window = clickData.func.sourcetab;
dlg.template = "SourcePicker";
dlg.detach = true;
dlg.Create();
var listView = dlg.Control("lvSources");
var buttonOK = dlg.Control("buttonOK");
var allItemsSelected = false;
var itemCount = 0;
var folderCandidates = [];
var dcimPaths = ["Z:\\DCIM"];
var mediaFolders =["102NZ6_2", "103NZ6_2"];
//adding´groups and items
for(var i = 0; i < dcimPaths.length; i++)
{
var dcimPath = dcimPaths[i];
var group = dlg.Control("lvSources").AddGroup(String(i), i);
for(var j = 0; j < mediaFolders.length; j++)
{
//var fsItem = DOpus.FSUtil.GetItem(mediaFolders[i])
var addedIndex = dlg.Control("lvSources").AddItem(mediaFolders[j], itemCount, group);
/*
var lvItem = dlg.Control("lvSources").GetItemAt(addedIndex);
lvItem.subitems(0) = fsItem.create.Format("D#yyyy-MM-dd T#HH-mm-ss");
lvItem.subitems(1) = fsItem.modify.Format("D#yyyy-MM-dd T#HH-mm-ss");
lvItem.subitems(2) = CountFolderMembers(fsItem);
*/
itemCount++;
}
}
listView.columns.AutoSize();
//enabling groupview
dlg.Control("lvSources").EnableGroupView(true);
dlg.Show();
while (true)
{
var msg = dlg.GetMsg();
if (!msg.result)
break;
DOpus.Output("Msg Event = " + msg.event + " by " + msg.control);
if (msg.event == "click")
{
if(msg.control == "buttonOK")
{
return;
}
}
}
}
function twoLoops(clickData)
{
var dlg = DOpus.Dlg;
dlg.window = clickData.func.sourcetab;
dlg.template = "SourcePicker";
dlg.detach = true;
dlg.Create();
var listView = dlg.Control("lvSources");
var buttonOK = dlg.Control("buttonOK");
var allItemsSelected = false;
var itemCount = 0;
var folderCandidates = [];
var dcimPaths = ["Z:\\DCIM"];
var mediaFolders =["102NZ6_2", "103NZ6_2"];
//adding groups
for(var i = 0; i < dcimPaths.length; i++)
{
var dcimPath = dcimPaths[i];
var group = dlg.Control("lvSources").AddGroup(String(i), i);
}
//enabling groupview
dlg.Control("lvSources").EnableGroupView(true);
//adding items to groups
for(var i = 0; i < dcimPaths.length; i++)
{
var dcimPath = dcimPaths[i];
for(var j = 0; j < mediaFolders.length; j++)
{
//var fsItem = DOpus.FSUtil.GetItem(mediaFolders[i])
var addedIndex = dlg.Control("lvSources").AddItem(mediaFolders[j], itemCount, i);//originally used the var "group" instead of i when i had just one loop
/*
var lvItem = dlg.Control("lvSources").GetItemAt(addedIndex);
lvItem.subitems(0) = fsItem.create.Format("D#yyyy-MM-dd T#HH-mm-ss");
lvItem.subitems(1) = fsItem.modify.Format("D#yyyy-MM-dd T#HH-mm-ss");
lvItem.subitems(2) = CountFolderMembers(fsItem);
*/
itemCount++;
}
}
listView.columns.AutoSize();
dlg.Show();
while (true)
{
var msg = dlg.GetMsg();
if (!msg.result)
break;
DOpus.Output("Msg Event = " + msg.event + " by " + msg.control);
if (msg.event == "click")
{
if(msg.control == "buttonOK")
{
return;
}
}
}
}
<resource name="SourcePicker" type="dialog">
<dialog fontsize="8" height="108" lang="english" title="Select source folders" width="498">
<control fullrow="yes" height="84" multisel="yes" name="lvSources" sort="yes" type="listview" viewmode="details" width="490" x="3" y="3">
<columns>
<item text="Path" />
<item text="Created" />
<item text="Modified" />
<item text="Children" />
</columns>
</control>
<control default="yes" enable="no" height="14" name="buttonOK" title="OK" type="button" width="50" x="3" y="91" />
<control close="0" height="14" name="buttonCancel" title="Cancel" type="button" width="50" x="444" y="91" />
<control height="14" name="buttonSelectAll" title="De/select all" type="button" width="93" x="154" y="91" />
<control height="14" name="buttonSelectAllAndContinue" title="De/select all and continue" type="button" width="93" x="251" y="91" />
</dialog>
</resource>