These forums are read-only and considered to be an archive. Please use the new Community for future interaction and posts.

File reference from component

I was wondering what the api was for gaining information from the component. What I am trying to do is integrate it as part of a CMS and use FileVista to allow users to click on a file which can then be opened in a WYSIWYG editor.

Is there any way to get a reference to the file clicked on in the component outside of FileVista, there doesn't seem to be much  documentation on the API
Shaun Doudican 2/22/2008 2:16 AM
We will implement a better API in the future releases but some hacks are possible.

On the client-side, you can get the name of the selected items with this code:

      for (var key in grid.selectedRows)
            alert(grid.selectedRows[key].cells[nameColumn.index]);

After you get the name of the selected items, you can initiate an AJAX call to post the names to a asmx or aspx page when you click a button.

Note that the above code shows you only the name of the files/folders.
You can get the path of the currently displayed folder with currentFolder.fullPath variable.
This variable will show the control specific path like "Root Folder Name\subfolder\" because on the client-side you should not know the underlying physical path for security reasons. However you can post currentFolder.rootFolderID variable to your server-side code and resolve the path as follows:

FileVistaRootFolder rootFolder =
FileVistaControl.SessionRootFolders[rootFolderID];
Response.Write(rootFolder.PhysicalPath);

This way your application can both know the physical path of the containing folder and selected files.

By the way, in v1.4 which is about to be released, we added Events which are raised by the file actions.
Cem Alacayir 2/22/2008 10:12 AM
Under this event in filevista.js:

function onSelectionComplete(e)

Does (e) have any properties like path etc?

I would like to fill a div with a link to the path of the file selected with a little dhtml.

I have tested that the following place exposes file selection where I have the alert('test') at...

function onSelectionComplete(e){var downloadButtonState=false;var downloadCommand="Download";if(grid.selectedCount==1){if(grid.getSelectedFirstRow().cells[groupColumn.index]==FOLDERGROUP){downloadButtonState=currentFolder.permission["Download"];downloadCommand="CompressAndDownload";}else
{alert('test');downloadButtonState=currentFolder.permission["Download"];}}else if(grid.selectedCount>1){downloadButtonState=currentFolder.permission["Download"];downloadCommand="CompressAndDownload";}
Daniel Penrod 3/10/2008 6:52 AM
Ok yeah

for (var key in grid.selectedRows)

Sorry!
Daniel Penrod 3/10/2008 7:26 AM
The latest version is 1.6, right?  Has there been new methods to do things like this?

I would like to trigger my own code when the user selects a file (load some profile information about the file, etc, in a form below the FolderVista form).

Also, is there a trigger post-upload that could get fired so I can do some other actions for each file uploaded?
Rich 1/2/2009 6:42 PM
No, there is no event for file selection as of v1.6.
Please see Obtaining the selected file in server side code for a sample implementation.

Below is an example code for implementing the Uploaded event. 

private static bool areHandlersAdded = false; 

protected void Page_Load(object sender, EventArgs e) 

                //Add your events within this if block
if (!areHandlersAdded) 

FileVistaControl.Uploaded += new EventHandler<FileVistaUploadedEventArgs>(FileVistaControl_Uploaded); 

areHandlersAdded = true; 



private void FileVistaControl_ Uploaded(object sender, FileVistaUploadedEventArgs e) 

//You can use e.RootFolder.MapPath(e.RelativePath) to 
//get the physical path of only the folder that the files are uploaded to 

//Get the paths of the uploaded files by walking through UploadedFiles collection 
string filePaths; 

foreach (GleamTech.Web.FileTransfer.UploadedFile uploadedFile in e.UploadProgress.UploadedFiles) 
filePaths += uploadedFile.FullPath + ", "; 
}
Cem Alacayir 1/9/2009 3:47 PM