Select to view content in your preferred language

OpenItemDialog local only (no portal)?

423
2
Jump to solution
07-25-2023 02:19 PM
KarlBeal
New Contributor II

Is it possible to set the OpenItemDialog to show only local items and not show anything from the portal? 

0 Kudos
1 Solution

Accepted Solutions
CharlesMacleod
Esri Regular Contributor

usually, by default, Portal isnt shown - at least in my case on v3.1:

OpenItemDialog itemDlg = new OpenItemDialog {
 Title = "Open Files",
 InitialLocation = @"E:\Data\Test",
 MultiSelect = false
};

bool? ok = itemDlg.ShowDialog();

 

if u do _not_ set a filter on the dialog then, by default, on construction, the itemDlg.Filters property shld be set to "esri_browseDialogFilters_gp_all" which excludes the portal "Node" by default....

However, if u need to force the Portal node to not show (because it is showing for some reason) then u can add an explicit "Exclude" to a browse filter:

BrowseProjectFilter bdf = new BrowseProjectFilter();
bdf.Name = "All files (*.*)";
bdf.BrowsingFilesMode = true;
bdf.FileExtension = "*.*";
bdf.Includes.Add(@"FolderConnection");
//Does not display Online places in the browse dialog
bdf.Excludes.Add(@"esri_browsePlaces_Online");
bdf.BrowsingFilesMode = true;

OpenItemDialog itemDlg = new OpenItemDialog {
 Title = "Open Files",
 InitialLocation = @"E:\Data\Test",
 MultiSelect = false,
 BrowseFilter = bdf
};

bool? ok = itemDlg.ShowDialog();

 

As the default filters usually exclude the Portal node, if you need to _add_ the portal Node, then construct a browse filter that does _not_ exclude it like so:

BrowseProjectFilter bdf = new BrowseProjectFilter();
bdf.Name = "All files (*.*)";
bdf.BrowsingFilesMode = true;
bdf.FileExtension = "*.*";
bdf.Includes.Add(@"FolderConnection");
bdf.BrowsingFilesMode = true;
//Do not exclude online places
//"Exclude" of Online places has been removed...

OpenItemDialog itemDlg = new OpenItemDialog {
 Title = "Open Files",
 InitialLocation = @"E:\Data\Test",
 MultiSelect = false,
 BrowseFilter = bdf
};

bool? ok = itemDlg.ShowDialog();

 

 

 

View solution in original post

2 Replies
CharlesMacleod
Esri Regular Contributor

usually, by default, Portal isnt shown - at least in my case on v3.1:

OpenItemDialog itemDlg = new OpenItemDialog {
 Title = "Open Files",
 InitialLocation = @"E:\Data\Test",
 MultiSelect = false
};

bool? ok = itemDlg.ShowDialog();

 

if u do _not_ set a filter on the dialog then, by default, on construction, the itemDlg.Filters property shld be set to "esri_browseDialogFilters_gp_all" which excludes the portal "Node" by default....

However, if u need to force the Portal node to not show (because it is showing for some reason) then u can add an explicit "Exclude" to a browse filter:

BrowseProjectFilter bdf = new BrowseProjectFilter();
bdf.Name = "All files (*.*)";
bdf.BrowsingFilesMode = true;
bdf.FileExtension = "*.*";
bdf.Includes.Add(@"FolderConnection");
//Does not display Online places in the browse dialog
bdf.Excludes.Add(@"esri_browsePlaces_Online");
bdf.BrowsingFilesMode = true;

OpenItemDialog itemDlg = new OpenItemDialog {
 Title = "Open Files",
 InitialLocation = @"E:\Data\Test",
 MultiSelect = false,
 BrowseFilter = bdf
};

bool? ok = itemDlg.ShowDialog();

 

As the default filters usually exclude the Portal node, if you need to _add_ the portal Node, then construct a browse filter that does _not_ exclude it like so:

BrowseProjectFilter bdf = new BrowseProjectFilter();
bdf.Name = "All files (*.*)";
bdf.BrowsingFilesMode = true;
bdf.FileExtension = "*.*";
bdf.Includes.Add(@"FolderConnection");
bdf.BrowsingFilesMode = true;
//Do not exclude online places
//"Exclude" of Online places has been removed...

OpenItemDialog itemDlg = new OpenItemDialog {
 Title = "Open Files",
 InitialLocation = @"E:\Data\Test",
 MultiSelect = false,
 BrowseFilter = bdf
};

bool? ok = itemDlg.ShowDialog();

 

 

 

KarlBeal
New Contributor II

I was using a feature class filter. The exclude example helped me get it working, thanks.

0 Kudos