The code that accomplishes that is as follows:
this.doUpOneLevel = function(inSelectedDirectory) {
// Only do something if a directory is selected.
if (inSelectedDirectory == null || inSelectedDirectory == "") {
return;
}
// Get the parent of the currently selected directory node and select
// it and refresh the grid, if the directory has a parent (file system
// roots wouldn't).
CHAPTER 6 n REMOTELY MANAGING YOUR FILES: DWR FILE MANAGER 306
var parentNodeID = directoryTree.getParentId(inSelectedDirectory);
if (parentNodeID != 0) {
directoryTree.selectItem(parentNodeID);
this.directoryClicked(parentNodeID);
}
} // End doUpOneLevel().
First, a quick check to be sure a directory is currently selected. Then, we use the
getParentId() method of the tree component to get the parent of the currently selected directory.
If that method returns 0, there is no parent (a file system root is selected), and we??™re done.
Otherwise, we call the selectItem() method of the tree component, passing it the parent node
ID we previously got. Finally, a call is made to directoryClicked(), which has the effect of
populating the file grid with the contents of the parent directory, since it??™s now the currently
selected directory.
Pages:
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551