Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    selectSingleRecord - how to make it visually reflect the selected record?

    using: SNAPSHOT_v9.0d_2013-04-30/PowerEdition Deployment (built 2013-04-30)

    same problem with any browser - using Chome Version 27.0.1453.110

    I have this simple line of code acting on a TreeGrid:
    Code:
    assetContainerTree.selectSingleRecord(assetContainersList.getSelectedRecord());
    When executed, it does appear to select the single record I wanted to select (as evidenced by firing of the selectionChanged event in assetContainerTree). However, there is no visual indication that the record was selected in the TreeGrid.

    How do I make it visually reflect the selected record in the TreeGrid control? (as if I had actually clicked on it which changes the background color of the selected item).
    Last edited by jerry426; 19 Jun 2013, 12:49.

    #2
    questionable progress....

    I've made some "progress"....

    Accidentally "discovered" that if I call the startEditing method on the selected TreeGrid record that it will put the keyboard cursor in the right place, then I call endEditing and the TreeGrid item is highlighted as I want... using this code:

    Code:
    click: function() {
       containerRecord = assetContainersList.getSelectedRecord();
       assetContainerTree.selectRecord(containerRecord);
       assetContainerTree.startEditing(assetContainerTree.data.indexOf(containerRecord));
       assetContainerTree.endEditing();
    }
    I'm hoping anyone that knows a "proper" way to achieve the result thus far will be able to:

    A: tell me the non-hackish way to do this.... if one exists.
    and
    B: tell me how to solve the NEXT problem, which is:

    The above only works IF the selected record is already visible in the TreeGrid - i.e. if I've already clicked on the + symbols needed to expand the tree such that the item is visible.

    How do I programmatically expand the TreeGrid such that the selected record is visible ??

    Thanks,
    Jerry

    Comment


      #3
      another battle victory

      For the benefit of the next person dealing with my problem, here's how I solved it:

      Code:
         function selectTreeGridNode(treeGrid, record, idValue, openAll) {
      
            // NOTE: for this to work, make sure the treeGrid setup includes:
            //    loadDataOnDemand: false
            // Also be aware of the size of the treeGrid's source data as this could result 
            // in loading a massive chunk of data into the treeGrid.
      
            // I originally suspected I'd also need to use "scrollToRow" in cases
            // where the expanded tree puts the target node out of sight, however, 
            // in my case it appears to automatically scroll to the selected node.
            
            if (openAll === true) {
               // optionally open the entire tree
               treeGrid.data.openAll();
            } else {
               // or only open the folders needed to expose the node we're selecting
               var targetNode = treeGrid.data.findById(idValue);
               var parentNodes = treeGrid.data.getParents(targetNode);
               treeGrid.data.openFolders(parentNodes);
            }
      
            // and finally, this silly trick seems to be the only way to put
            // highlighted focus on the record being selected
            var canEditOriginalState = treeGrid.canEdit;
            treeGrid.canEdit = true;
            treeGrid.startEditing(treeGrid.data.indexOf(record));
            treeGrid.endEditing();
            treeGrid.canEdit = canEditOriginalState;
      
         }
      As always, I'd love to hear from anyone about a better approach to solving this. And if there isn't one, then perhaps Isomorphic wouldn't mind incorporating a functionally equivalent version of my code into the API to make this into a simple/included feature.

      Thanks,
      Jerry
      Last edited by jerry426; 4 Sep 2013, 06:07. Reason: slightly improved my code example

      Comment

      Working...
      X