Announcement

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

    Setting auto open for certain nodes

    Hey,

    I'm using release SmartClient_v83p_2013-02-06 and I'm trying to set certain nodes open state be default.
    I've managed to do it by using
    Code:
     dataProperties: { openProperty: "isOpen" }
    but whenever I re-fetch the data with the fetchData function the tree ignore the isOpen setting that is being returned by the server.

    Why?

    You can reproduce this by using the example you have in the feature explorer - Tree - Load XML (Parent Links).

    Use this file (employeesDataParentLinked.xml):

    Code:
    <Employees>
        <employee>
    		<EmployeeId>7</EmployeeId>
    		<ReportsTo>1</ReportsTo>
    		<Name>Charles Madigen</Name>
            <isOpen>false</isOpen>
    		<Job>Chief Operating Officer</Job>
        </employee>
        <employee>
            <EmployeeId>188</EmployeeId>
            <ReportsTo>7</ReportsTo>
            <Name>Rogine Leger</Name>
            <Job>Mgr Syst P P</Job>
        </employee>
        <employee>
            <EmployeeId>189</EmployeeId>
            <ReportsTo>7</ReportsTo>
            <Name>Gene Porter</Name>
            <Job>Mgr Tech Plng IntIS T</Job>
        </employee>
        <employee>
            <EmployeeId>265</EmployeeId>
            <ReportsTo>189</ReportsTo>
            <Name>Olivier Doucet</Name>
            <Job>Asset Spec Lines Stns</Job>
        </employee>                            
        <employee>
            <EmployeeId>264</EmployeeId>
            <ReportsTo>189</ReportsTo>
            <Name>Cheryl Pearson - Deddy is a Monkey</Name>
            <Job>Dsl Sys Rep</Job>
        </employee>
    </Employees>
    and use this initiation:

    Code:
    isc.DataSource.create({
        ID:"employees",
        dataURL:"/isomorphic/system/reference/inlineExamples/trees/dataBinding/employeesDataParentLinked.xml",
        recordXPath:"/Employees/employee",
        fields:[
            {name:"Name"},
            {name:"Job"},
            {name:"EmployeeId", primaryKey:true, type:"integer", title:"Employee ID"},
            {name:"ReportsTo", foreignKey:"employees.EmployeeId", type:"integer", title:"Manager"}
        ]
    });
    
    isc.VLayout.create({
    
    members: [
    
    isc.TreeGrid.create({
        ID: "employeeTree",
        dataSource: "employees",
        autoFetchData: true,
    dataProperties: { openProperty: "isOpen"},
        loadDataOnDemand: false,
    
        // customized appearance
        width: 500,
        height: 400,
        nodeIcon:"icons/16/person.png",
        folderIcon:"icons/16/person.png",
        showOpenIcons:false,
        showDropIcons:false,
        closedIconSuffix:""
    }),
    
    isc.Label.create({
    
    contents: "Fetch",
    click: function() {
    
    employeeTree.fetchData({name:new Date()});
    }})]});
    Now, change the false to true in the isOpen tag and click on the Fetch button and you can see that the node is not open.

    #2
    You need to declare the field "isOpen" in the DataSource as type boolean or you're causing a String value to be stored in the openProperty, which the Tree will not understand.

    Comment


      #3
      This is the data source I'm using

      Code:
      <DataSource ID="side.pane.tree"
                  lookupStyle="new"
                  serverType="generic"
                  dropExtraFields="true">
      
          <fields>
      
              <field name="parentId"
                     type="string"/>
      
              <field name="separator"
                     type="boolean"/>
      
              <field name="hasNoChildren"
                     type="boolean"/>
      
              <field name="name"
                     type="string"/>
      
              <field name="icon"
                     type="string"/>
      
              <field name="id"
                     type="string"/>
      
              <field name="isOpen"
                     type="boolean"/>
      
              <field name="contextMenu"
                     type="string"/>
      
          </fields>
      
          <serverObject className="com.msp.eui.smartclient.datasource.dmihandler.impl.SidePaneDataSourceDMIHandler"/>
      
      </DataSource>
      The isOpen is set to boolean. I remind you that I see the nodes open the first time the tree load but when I use fetchData it stop working.

      Comment


        #4
        Using the SDK example and adding the required field definition, everything works as expected.

        Code:
                {name:"isOpen", type:"boolean"}
        It looks like you didn't test the SDK example and you're actually talking about a problem in unrelated code. If you need help with that, provide the usual troubleshooting information about that setup (responses shown in RPC tab, etc).

        Comment


          #5
          I provided a way to reproduce the problem with your examples. I can't provide working example because the problem occur when working with a server.

          In order to see the problem you will need to load data when the root node isOpen is set to false. Then, use fetchData with different criteria to load different data when the root node isOpen is set to true. You will see that the node will not be opened.

          Please try it out I promise that you will be able to reproduce it.

          Comment


            #6
            We did. There was a problem with your approach, and it is fixed by adding the field definition we showed.

            Comment


              #7
              I added this definition and now I can see checkbox column. The first time the tree is loaded I can see the checkbox checked where the isOpen property is true but after I use fetchData although the data returned with isOpen true the checkbox is not checked. What should I do?

              I just found out more details about the issue. I can clearly see that the response that return the data as json contain isOpen : true in a certain node which show the checkbox unchecked. When debugging the nodeClick function I can see that the node have isOpen false, buy why?
              Last edited by RotemMSP; 20 Feb 2013, 14:06.

              Comment


                #8
                We don't know whether you're now talking about the code based on the sample or some other code.

                The code based on the sample doesn't have this problem.

                Any number of things could cause the value to be changed in your own system - we don't have enough information to even speculate.

                Comment


                  #9
                  Ok, so please tell me what I need to provide in order to help you diagnose the problem?

                  Comment


                    #10
                    At this point, we've done quite a bit of investigation and found no hint of a framework issue. So if you'd like this looked into as a possible framework bug, please provide a minimal, ready-to-run test case demonstrating a framework bug.

                    Comment


                      #11
                      I did provide a way to reproduce the problem. Again let me clarify the test case.

                      Please use the XML I provided with the TreeGrid + Button. Secondly, you load the tree and see that the 'Charles Madigen' node is not open. Third, you go to the XML, change the isOpen to true and the name to 'Charles Madigen 2'. Then, you need to press the Fetch button (Not reload the page) and then you will see that the name changed to 'Charles Madigen 2' but the node is not opened.

                      It's very important that you will not open the node manually before step three, remember the node have to be opened by the isOpen property.

                      Thank you.

                      Comment


                        #12
                        Right, that's how we already tested it, it works fine once you add the DataSource field definition as explained in post 2 and shown in post 4.

                        Comment


                          #13
                          Ok, so after investigating even more I found out how to fix the problem.

                          This is the definition of my dataProperties.

                          Code:
                          dataProperties:{
                                  isOpen:function(node){
                                    return this.Super('isOpen', node) || node.isOpen;
                                  }
                                },
                          No need for the openProperty: "isOpen".

                          Comment


                            #14
                            Just to make sure no one copies this - this is not needed, and not recommended. It has no effect on the sample code, and if it works in some application code this user hasn't shared, that suggests that their code is not correctly setting openProperty.

                            Comment


                              #15
                              I will be more then happy to share our implementation with you but I don't know how I suppose to provide a test case with all of our usage.

                              If you can do a quick session on TeamViewer or equivalent in order to get to the bottom of this it would be great.

                              Edit: I can paste here the DS, ListGrid and the Json that is returned from the server, will that help?

                              Comment

                              Working...
                              X