jQWidgets Forums

jQuery UI Widgets Forums TreeGrid Bug in TreeGrid?

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 10 years, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Bug in TreeGrid? #64099

    prernarana
    Participant

    I was exploring your example to render nested XML. I removed <LastName>Fuller</LastName> from the XML and re-rendered the TreeGrid,
    It actually picked up “Callahan” from the subsequent node and displayed it on the treegrid.

    I am facing the same problem in my code when some XML tag is missing, tree grid still displays the data for that tag picking it from some other node of XML.

    Please Help!!

    what I did :

    <?xml version="1.0"?>
    <Employees>
      <Employee EmployeeID="2">
                                     <<< removed the LastName tag from here....
        <FirstName>Andrew</FirstName>
        <Title>Vice President, Sales</Title>
        <TitleOfCourtesy>Dr.</TitleOfCourtesy>
        <BirthDate>1952-02-19</BirthDate>
        <HireDate>1992-08-14</HireDate>
        <Address>908 W. Capital Way</Address>
        <City>Tacoma</City>
        <Region>WA</Region>
        <PostalCode>98401</PostalCode>
        <Extension>3457</Extension>
        <Notes>Andrew received his BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981.  He is fluent in French and Italian and reads German.  He joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993.  Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.</Notes>
        <Employees>
          <Employee EmployeeID="8">
            <LastName>Callahan</LastName>
            <FirstName>Laura</FirstName>
            <Title>Inside Sales Coordinator</Title>
            <TitleOfCourtesy>Ms.</TitleOfCourtesy>
            <BirthDate>1958-01-09</BirthDate>
            <HireDate>1994-03-05</HireDate>
            <Address>4726 - 11th Ave. N.E.</Address>
            <City>Seattle</City>
            <Region>WA</Region>
            <PostalCode>98105</PostalCode>
            <Extension>2344</Extension>
            <Notes>Laura received a BA in psychology from the University of Washington.  She has also completed a course in business French.  She reads and writes French.</Notes>
          </Employee>
          <Employee EmployeeID="1">
            <LastName>Davolio</LastName>
            <FirstName>Nancy</FirstName>
            <Title>Sales Representative</Title>
            <TitleOfCourtesy>Ms.</TitleOfCourtesy>
            <BirthDate>1948-12-08</BirthDate>
            <HireDate>1992-05-01</HireDate>
            <Address>
              507 - 20th Ave. E.
              Apt. 2A
            </Address>
            <City>Seattle</City>
            <Region>WA</Region>
            <PostalCode>98122</PostalCode>
            <Extension>5467</Extension>
            <Notes>Education includes a BA in psychology from Colorado State University in 1970.  She also completed "The Art of the Cold Call."  Nancy is a member of Toastmasters International.</Notes>
          </Employee>
          <Employee EmployeeID="5">
            <LastName>Buchanan</LastName>
            <FirstName>Steven</FirstName>
            <Title>Sales Manager</Title>
            <TitleOfCourtesy>Mr.</TitleOfCourtesy>
            <BirthDate>1955-03-04</BirthDate>
            <HireDate>1993-10-17</HireDate>
            <Address>14 Garrett Hill</Address>
            <City>London</City>
            <Region/>
            <PostalCode>SW1 8JR</PostalCode>
            <Extension>3453</Extension>
            <Notes>Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976.  Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London.  He was promoted to sales manager in March 1993.  Mr. Buchanan has completed the courses "Successful Telemarketing" and "International Sales Management."  He is fluent in French.</Notes>
            <Employees>
              <Employee EmployeeID="9">
                <LastName>Dodsworth</LastName>
                <FirstName>Anne</FirstName>
                <Title>Sales Representative</Title>
                <TitleOfCourtesy>Ms.</TitleOfCourtesy>
                <BirthDate>1966-01-27</BirthDate>
                <HireDate>1994-11-15</HireDate>
                <Address>7 Houndstooth Rd.</Address>
                <City>London</City>
                <Region/>
                <PostalCode>WG2 7LT</PostalCode>
                <Extension>452</Extension>
                <Notes>Anne has a BA degree in English from St. Lawrence College.  She is fluent in French and German.</Notes>
              </Employee>
              <Employee EmployeeID="7">
                <LastName>King</LastName>
                <FirstName>Robert</FirstName>
                <Title>Sales Representative</Title>
                <TitleOfCourtesy>Mr.</TitleOfCourtesy>
                <BirthDate>1960-05-29</BirthDate>
                <HireDate>1994-01-02</HireDate>
                <Address>
                  Edgeham Hollow
                  Winchester Way
                </Address>
                <City>London</City>
                <Region/>
                <PostalCode>RG1 9SP</PostalCode>
                <Extension>465</Extension>
                <Notes>Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company.  After completing a course entitled "Selling in Europe," he was transferred to the London office in March 1993.</Notes>
              </Employee>
              <Employee EmployeeID="6">
                <LastName>Suyama</LastName>
                <FirstName>Michael</FirstName>
                <Title>Sales Representative</Title>
                <TitleOfCourtesy>Mr.</TitleOfCourtesy>
                <BirthDate>1963-07-02</BirthDate>
                <HireDate>1993-10-17</HireDate>
                <divya>            
                	<Address>
                		<prerna>
                  		Coventry House,divya
                  		Miner Rd.
                  		</prerna>
                	</Address>
                </divya>
                <City>London</City>
                <Region/>
                <PostalCode>EC2 7JR</PostalCode>
                <Extension>428</Extension>
                <Notes>Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986).  He has also taken the courses "Multi-Cultural Selling" and "Time Management for the Sales Professional."  He is fluent in Japanese and can read and write French, Portuguese, and Spanish.</Notes>
              </Employee>
            </Employees>
          </Employee>
          <Employee EmployeeID="3">
            <LastName>Leverling</LastName>
            <FirstName>Janet</FirstName>
            <Title>Sales Representative</Title>
            <TitleOfCourtesy>Ms.</TitleOfCourtesy>
            <BirthDate>1963-08-30</BirthDate>
            <HireDate>1992-04-01</HireDate>
            <divya>            
                	
                </divya>
            <City>Kirkland</City>
            <Region>WA</Region>
            <PostalCode>98033</PostalCode>
            <Extension>3355</Extension>
            <Notes>Janet has a BS degree in chemistry from Boston College (1984).  She has also completed a certificate program in food retailing management.  Janet was hired as a sales associate in 1991 and promoted to sales representative in February 1992.</Notes>
          </Employee>
          <Employee EmployeeID="4">
            <LastName>Peacock</LastName>
            <FirstName>Margaret</FirstName>
            <Title>Sales Representative</Title>
            <TitleOfCourtesy>Mrs.</TitleOfCourtesy>
            <BirthDate>1937-09-19</BirthDate>
            <HireDate>1993-05-03</HireDate>
            <Address>4110 Old Redmond Rd.</Address>
            <City>Redmond</City>
            <Region>WA</Region>
            <PostalCode>98052</PostalCode>
            <Extension>5176</Extension>
            <Notes>Margaret holds a BA in English literature from Concordia College (1958) and an MA from the American Institute of Culinary Arts (1966).  She was assigned to the London office temporarily from July through November 1992.</Notes>
          </Employee>
        </Employees>
      </Employee>
    </Employees>
    

    Code For tree grid:

    <!DOCTYPE html>
    <html lang=”en”>
    <head>
    <title id=”Description”>Data Binding to Nested XML data in jqxTreeGrid.</title>
    <meta name=”description” content=”This sample demonstrates how we can bind jQWidgets TreeGrid widget to Nested XML Data by using jQWidgets DataAdapter plugin.”>
    <link rel=”stylesheet” href=”../../jqwidgets/styles/jqx.base.css” type=”text/css” />
    <script type=”text/javascript” src=”../../scripts/jquery-1.11.1.min.js”></script>
    <script type=”text/javascript” src=”../../jqwidgets/jqxcore.js”></script>
    <script type=”text/javascript” src=”../../jqwidgets/jqxdata.js”></script>
    <script type=”text/javascript” src=”../../jqwidgets/jqxbuttons.js”></script>
    <script type=”text/javascript” src=”../../jqwidgets/jqxscrollbar.js”></script>
    <script type=”text/javascript” src=”../../jqwidgets/jqxdatatable.js”></script>
    <script type=”text/javascript” src=”../../jqwidgets/jqxtreegrid.js”></script>
    <script type=”text/javascript” src=”../../scripts/demos.js”></script>
    <script type=”text/javascript”>
    $(document).ready(function () {
    // prepare the data
    var url = “../sampledata/employeesadv.xml”;

    var source =
    {
    dataType: “xml”,
    dataFields: [
    { name: ‘EmployeeID’, type: ‘number’ },
    { name: ‘ReportsTo’, type: ‘number’ },
    { name: ‘FirstName’, type: ‘string’ },
    { name: ‘LastName’, type: ‘string’ },
    { name: ‘City’, type: ‘string’ },
    { name: ‘Address’, type: ‘string’ },
    { name: ‘Title’, type: ‘string’ },
    { name: ‘HireDate’, type: ‘date’ },
    { name: ‘BirthDate’, type: ‘date’ }
    ],
    hierarchy:
    {
    // defines the root and record of each hiearchy level.
    root: ‘Employees’,
    record: ‘Employee’
    },
    id: ‘EmployeeID’,
    root: ‘Employees’,
    record: ‘Employee’,
    url: url
    };

    var dataAdapter = new $.jqx.dataAdapter(source);
    // create Tree Grid
    $(“#treeGrid”).jqxTreeGrid(
    {
    width: 850,
    source: dataAdapter,
    columnsResize: true,
    ready: function () {
    // expand row with ‘EmployeeKey = 2’
    $(“#treeGrid”).jqxTreeGrid(‘expandRow’, 2);
    },
    columns: [
    { text: ‘FirstName’, dataField: ‘FirstName’, minWidth: 100, width: 200 },
    { text: ‘LastName’, dataField: ‘LastName’, width: 200 },
    { text: ‘Title’, dataField: ‘Title’, width: 300 },
    { text: ‘Address’, dataField: ‘Address’, width: 200 },
    { text: ‘City’, dataField: ‘City’, width: 150 },
    { text: ‘Birth Date’, dataField: ‘BirthDate’, cellsFormat: ‘d’, width: 120 },
    { text: ‘Hire Date’, dataField: ‘HireDate’, cellsFormat: ‘d’, width: 120 }
    ]
    });
    });
    </script>
    </head>
    <body class=’default’>
    <div id=”treeGrid”>
    </div>
    </body>
    </html>`

    Please help me with the solution for this.
    secondly, Can I keep a default value for a Column if the data is missing or empty for that column?

    Regards,
    Prerna

    Bug in TreeGrid? #64102

    Peter Stoev
    Keymaster

    Hi prernarana,

    You shouldn’t have missing tags in the XML when these are specified. The tag may be with empty value but it shouldn’t be missing. This is a bug in the xml, not in the treegrid.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Bug in TreeGrid? #64132

    prernarana
    Participant

    Can I specify a default value if a tag is missing?

    Bug in TreeGrid? #64135

    Peter Stoev
    Keymaster

    Hi prernarana,

    For Valid XML, tags shouldn’t be missing.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.