Need to obtain names of user selected\highlighted files please
Question asked by Serge Zee - August 3 at 2:41 PM
Answered
Hi , 
I need to be able to select user chosen/highlighted items and the pass these values to JavaScript, It used to work ok in previous versions with grid.selectedItems code. 
Now it does not. 
I tried ClientChosen event and it works ok, but then FileVista control view disappears. I tried your sample project and that's the behavior i experienced. 
So, i wonder if this can not be resolved, then if there is some alternative way to find 
user selected/highlighted items? 
Thank You 
Serge

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post
There is no direct event for it (we plan to add it in future) but for now you can use this code:
 
<head> 
  <script type="text/javascript">
  
    //Override for adding getNavigationSelectionInfo amd getViewSelectionInfo methods
    //and fileManagerNavigationSelectionChange and fileManagerViewSelectionChange events
    function fileManagerLoading(sender, e) {
        var fileManager = sender;

        Ext.override(fileManager, {
            getNavigationSelectionInfo: function () {
                var record = this.navigationSelection;

                if (!record)
                    return null;

                return {
                    Name: record.data.name,
                    FullPath: record.getPathData().fullPath,
                    ItemType: Ext.Object.getKey(GleamTech.FileUltimate.FileManagerItemType, record.data.itemType)
                };
            },
            getViewSelectionInfo: function() {
                var parentFullPath = this.navigationSelection.getPathData().fullPath;

                var items = [];
                for (var i = 0; i < this.viewSelection.length; i++) {
                    var record = this.viewSelection[i];

                    items.push({
                        Name: record.data.name,
                        FullPath: GleamTech.Util.Path.combine(parentFullPath, record.data.name, GleamTech.Util.Path.backSlash),
                        ItemType: Ext.Object.getKey(GleamTech.FileUltimate.FileManagerItemType, record.data.itemType),
                        Extension: record.data.extension,
                        Size: record.data.size
                    });
                }

                return items;
            },
            onNavigationSelectionChange: function() {
                this.callParent(arguments);

                var eventArgs = this.getNavigationSelectionInfo();

                if (eventArgs)
                    Ext.callback(window["fileManagerNavigationSelectionChange"], window, [this, eventArgs]);
            },
            onViewSelectionChange: function () {
                this.callParent(arguments);

                var eventArgs = this.getViewSelectionInfo();

                Ext.callback(window["fileManagerViewSelectionChange"], window, [this, eventArgs]);
            }
        });
    }

  </script>
</head> 
<body>

  <GleamTech:FileManager id="fileManager" runat="server" 
    ClientLoading="fileManagerLoading" />
  
</body>
 
Then for navigation selection:
 
//OPTION 1:
function fileManagerNavigationSelectionChange(sender, e) {
    //Pretty print the navigation selection (from event object) when it changes
    alert(JSON.stringify(e, null, 2));
}

//OPTION 2:
function myButton1Click() {
    //Pretty print the navigation selection when the your button is clicked
    var selection = fileManager.getViewSelectionInfo();
    alert(JSON.stringify(selection, null, 2));
}

//SAMPLE OUTPUT:
/*

{
  "Name": "Folder One",
  "FullPath": "[1. Root Folder]:\\Folder One",
  "ItemType": "Folder"
}

*/
 
 
Then for view selection:
 
//OPTION 1:
function fileManagerViewSelectionChange(sender, e) {
    //Pretty print the view selection (from event object) when it changes
    alert(JSON.stringify(e, null, 2));
}

//OPTION 2:
function myButton2Click() {
    //Pretty print the view selection when the your button is clicked
    var selection = fileManager.getNavigationSelectionInfo();
    alert(JSON.stringify(selection, null, 2));
}


//SAMPLE OUTPUT:
/*

[
  {
    "Name": "DOCX Document.docx",
    "FullPath": "[1. Root Folder]:\\DOCX Document.docx",
    "ItemType": "File",
    "Extension": "docx",
    "Size": 84272
  },
  {
    "Name": "Folder One",
    "FullPath": "[1. Root Folder]:\\Folder One",
    "ItemType": "Folder",
    "Extension": "",
    "Size": null
  }
]

*/
 

Reply to Thread