Announcement

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

    TreeGrid.getSelection() vs. hidden

    Hi,

    I'm having issues with the getSelection() method on TreeGrid components which are marked
    with visibility == 'hidden'. I use the 'selectionProperty' along with the 'initialData' to feed the TreeGrid.

    The getSelection() returns an empty collection unless the TreeGrid gets rendered at least once.

    Here's the code I use:

    Code:
    var treeGrid = MeiTreeGrid.create
    ({
    	dataSource : this.treeDataSource,
    	dataProperties : { openProperty: 'isOpen' },
    	isFolderProperty : 'isFolder',
    	selectionProperty : 'isSelected',
    	nodeIcon : this.dimIcons.find('name', dimName).icon,
    	folderIcon : this.dimIcons.find('name', dimName).icon,
    	selectionAppearance : 'checkbox',
    	leaveScrollbarGap : false,
    	layoutMargin : 0,
    	width : '100%',
    	height : '100%',
    	layoutMargin : 0,
    	membersMargin : 0,
    	visibility : 'hidden',
    	initialData : initRecords,
    	fields : [ { name : 'caption', treeField : true } ]
    });
    
    // returns an empty collection unless TreeGrid has rendered at least once
    
    var selections = treeGrid.getSelection();
    Is there anything I can do to have the getSelection() return selections prior to having the tree rendered first?

    Thanks,

    #2
    This looks like it's no longer the case with recent versions. With older versions, calling setFields() with no arguments should initialize the selection model.

    Comment


      #3
      Unfortunately that doesn't work. We use 7.0 RC2 and I've tried calling setFields() on the TreeGrid, but that didn't help.

      Any other suggestions?

      Comment


        #4
        Ok you can achieve this in 7.0RC2 by initializing the data as an actual ResultTree object rather than using initialData.
        Here's a modification to the standard initial data / load on demand treeGrid example that demonstrates this:

        Code:
        var data = isc.ResultTree.create({
        dataSource:employees,
        openProperty:"isOpen",
        data:[
                {EmployeeId:"4", ReportsTo:"1", Name:"Charles Madigen", Job:"Chief Operating Officer", 
                 isOpen: true},
                {EmployeeId:"192", isSel:true, ReportsTo:"4", Name:"Ralph Brogan", Job:"Mgr Software Client Supp"},
                {EmployeeId:"191", ReportsTo:"4", Name:"Tammy Plant", Job:"Mgr Cap Rptg Dist"},
                {EmployeeId:"190", ReportsTo:"4", Name:"Carol Finley", Job:"Mgr Fin Rpts Budgets"},
                {EmployeeId:"189", ReportsTo:"4", Name:"Gene Porter", Job:"Mgr Tech Plng IntIS T"},
                {EmployeeId:"188", ReportsTo:"4", Name:"Rogine Leger", Job:"Mgr Syst P P"}, 
                {EmployeeId:"187", ReportsTo:"4", Name:"Abigail Lippman", Job:"Mgr Proj Del"}, 
                {EmployeeId:"186", ReportsTo:"4", Name:"John Garrison", Job:"Mgr Site Services"}, 
                {EmployeeId:"185", ReportsTo:"4", Name:"Rui Shu", Job:"Mgr Proj Del", Phone:"x29930"}, 
                {EmployeeId:"184", ReportsTo:"4", Name:"Kirill Amirov", Job:"Mgr Tech Plng IntIS T"}, 
                {EmployeeId:"183", ReportsTo:"4", Name:"Joan Little", Job:"Mgr Ther Gen", Phone:"x18451"}, 
                {EmployeeId:"183", ReportsTo:"4", Name:"Joan Little", Job:"Mgr Ther Gen", Phone:"x18451"}, 
                {EmployeeId:"182", ReportsTo:"4", Name:"Tamara Kane", Job:"Mgr Site Services"}
            ],
        
        });
        
        isc.TreeGrid.create({
            ID: "employeeTree",
            dataSource: "employees",
            selectionAppearance:"checkbox",
            data:data,
            autoDraw:false,
            selectionProperty:"isSel",
            // customize appearance
            fields: [
                {name: "Name"},
                {name: "Job"}
            ],
            width: 500,
            height: 400,
            nodeIcon:"icons/16/person.png",
            folderIcon:"icons/16/person.png",
            showOpenIcons:false,
            showDropIcons:false,
            closedIconSuffix:""
        });
        
        isc.Log.logWarn("employeeTree.sel:" + isc.Log.echo( employeeTree.getSelection()));
        Note that the log, which fires before the treegrid is drawn will show the selected record (set up via the 'isSel' property).
        (Also not that the dataSource on the ResultTree is set to point to the employees dataSource directly - using the string "employees" wouldn't work).

        Let us know if this doesn't work for you

        Thanks
        Isomorphic Software

        Comment


          #5
          Thanks,

          That approach works.

          By the way, isn't 7.0RC2 the latest available version? One of your replies seemed to
          indicate a newer version was available ... Also, when will 7.0 become GA ?

          Thanks again for your help!

          Comment


            #6
            7.0rc2 is a supported release, there will be a 7.1 that mostly collects patches to 7.0rc2, and nightlies of 8.0 are available at smartclient.com/builds

            Comment


              #7
              Thanks very much for those additional details!

              Would you recommend we upgrade to your 8.0 nightly builds ? How stable is it ? What is the planned GA date for 8.0 ?

              Thanks,

              Comment

              Working...
              X