jQWidgets Forums

jQuery UI Widgets Forums Grid Data Rows Interspersed with Blank Rows

This topic contains 6 replies, has 2 voices, and was last updated by  shimmoril 13 years ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author

  • shimmoril
    Participant

    I have a grid I’m loading via XML. The XML is being returned correctly, but when the grid is rendered each ‘data’ row is followed by an empty row, like so:

    User Project Course
    Bob A-1 Cats

    Jane G-8 Dogs

    Jill R-5 Birds

    Here’s the code:

    var source = {
    datatype: "xml",
    datafields: [
    {name: 'ID', map: '\\ID', type: 'number'},
    {name: 'User', map: '\\User', type: 'string'},
    {name: 'Project', map: '\\ProjectName', type: 'string'},
    {name: 'Course', map: '\\CourseName', type: 'string'}
    ],
    root: "Report",
    record: "User",
    id: '\\ID',
    url: url,
    sort: function(params) { $("##reportGrid").jqxGrid('updatebounddata'); },
    filter: function(params, data) { $("##reportGrid").jqxGrid('updatebounddata'); },
    };

    var dataAdapter = new $.jqx.dataAdapter(source);

    var rendergridrows = function (params) { return dataAdapter.records; }

    //create grid
    $("##reportGrid").jqxGrid ({
    width: 600,
    source: dataAdapter,
    theme: theme,
    rendergridrows: rendergridrows,
    columns: [
    {text: 'ID', datafield: 'ID', width: 170},
    {text: 'User', datafield: 'User', width: 170},
    {text: 'Project', datafield: 'Project', width: 111},
    {text: 'Course', datafield: 'Course', width: 111},
    ]
    });

    I will eventually be using database paging for this grid, which is why it’s set up w/ the data adapter and the rendergridrows, but even when I remove those items I get the same results.


    Peter Stoev
    Keymaster

    Hi shimmoril,

    I will not be able to reproduce the reported behavior without a sample XML. In addition, you should not put ‘,’ in the last item of an array. Some browsers like IE8 will detect a syntax error.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    shimmoril
    Participant

    Here’s the XML as returned by Firebug:

    <?xml version="1.0" encoding="UTF-8"?>
    <Report>
    <User>
    <ID>2204</ID>
    <User>Doe, Jane</User>
    <CourseName>Test Course Alpha</CourseName>
    <ProjectName>Test Project Alpha</ProjectName>
    <TotalRows>6</TotalRows>
    </User>
    <User>
    <ID>2302</ID>
    <User>Doe, Jane</User>
    <CourseName>Test Course Gamma</CourseName>
    <ProjectName>Test Project Beta</ProjectName>
    <TotalRows>6</TotalRows>
    </User>
    <User>
    <ID>2284</ID>
    <User>Doh, John</User>
    <CourseName>Test Course Beta</CourseName>
    <ProjectName>Test Project Alpha</ProjectName>
    <TotalRows>6</TotalRows>
    </User>
    <User>
    <ID>2329</ID>
    <User>Smith, Barb</User>
    <CourseName>Test Course Epsilon</CourseName>
    <ProjectName>Test Project Beta</ProjectName>
    <TotalRows>6</TotalRows>
    </User>
    <User>
    <ID>2330</ID>
    <User>Symthe, Adele</User>
    <CourseName>Test Course Iota</CourseName>
    <ProjectName>Test Project Beta</ProjectName>
    <TotalRows>6</TotalRows>
    </User>
    </Report>

    Nice catch on the comma, we’ve run into that a few times ourselves. I’m doing all my testing in FF13, but I’ve removed it anyway.


    shimmoril
    Participant

    There is a blank line between each User node, and a blank line separates the Report tags from the first/last child nodes, but this is true of all of our XML-populated grids, none of which have this problem.

    Also, there are 6 records. If paging is on, only 6 rows are shown – 3 w/ data and three without. The number of rows is correctly reflected in the grid footer, and you cannot change the page. Changing the page size also doesn’t display any more rows. If paging is turned off, all 12 rows (6 w/ data and 6 w/o) are shown.


    shimmoril
    Participant

    Okay, so further investigation shows that while the XML returned has 6 rows of data, when I add in an alert that shows dataAdapter.records[i].User I’m getting an alert w/ the first user’s name, then a blank alert, then the second user’s name etc. For some reason the source or dataAdapter isn’t reading the result properly.

    This is my alert code:

    var rendergridrows = function (params) {
    for (var i=0; i<10; i++) {
    alert(dataAdapter.records[i].User);
    }
    return dataAdapter.records;
    }


    Peter Stoev
    Keymaster

    Hi shimmoril,

    There’s an issue with the XML file because the “User” is set as a record, but you also have a child node called “User”.

    <User>
    <ID>2330</ID>
    <User>Symthe, Adele</User>
    <CourseName>Test Course Iota</CourseName>
    <ProjectName>Test Project Beta</ProjectName>
    <TotalRows>6</TotalRows>
    </User>

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    shimmoril
    Participant

    Oh wow. And that’s why starting at code for hours is a bad thing! Thanks Peter, that fixed the issue.

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

You must be logged in to reply to this topic.