Author Topic: grid display does not format correctly  (Read 3107 times)

steveferg

  • Newbie
  • *
  • Posts: 4
    • View Profile
grid display does not format correctly
« on: July 16, 2016, 02:06:32 am »
I just started trying to work with paramquery using an xml file. I basically copy and pasted from the xml demo renaming the fields to what I wanted to use. The output display is attached, using the xml file below the code. My entire aspx file is below. No matter what demo I use, I get similar odd ball results. I've tried the free version and the eval pro version with the same results. I am using IE 10. What am I doing wrong?


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserMaintenance.aspx.cs" Inherits="UserMaintenance" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   <!--jQuery dependencies-->
 <link rel="stylesheet"
     href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" />
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>   
 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
 
 <!--Include Touch Punch file to provide support for touch devices-->
 <script type="text/javascript" src="/js/grid-2.0.4/touch-punch/touch-punch.min.js" ></script>   
 
 <!--ParamQuery Grid files-->
 <link rel="stylesheet" href="/js/grid-2.0.4/pqgrid.min.css" />
 <script type="text/javascript" src="/js/grid-2.0.4/pqgrid.min.js" ></script>
 <script type="text/javascript">

    $(function () {
        var colModel = [
          { title: "User Name", dataType: "string", width: "120", dataIndx: 0 },
          { title: "Email", dataType: "string", width: "150", dataIndx: 1 },
          { title: "Role", dataType: "string", width: "120", dataIndx: 2 },
          { title: "Created", dataType: "string", width: "120", dataIndx: 3 },
          { title: "Last Accessed", dataType: "string", width: "120", dataIndx: 4 },
          { title: "Login Count", dataType: "string", width: "120", dataIndx: 5 },
            { title: "Comment", dataType: "string", width: "120", dataIndx: 6 }
      ];

        var dataModel = {
            cache: true,
            location: "remote",                                   
            sortDir: "down",
            sorting: "local",                       
            dataType: "xml",
            url: "/UserStats.xml",           
            getData: function (dataDoc) {
                //debugger;
                //$(dataDoc).find("price").each(function(i,pNode){
                //    var txt=$(pNode).text();
                //    txt=txt.replace("$","");
                //    $(pNode).text(txt);                   
                //});                               
                var obj = { itemParent: "Account", itemNames: ["Username", "Email", "Role", "CreationDate", "LastAccessed", "LoginCount", "Comment"] };
                return { data: $.paramquery.xmlToArray(dataDoc, obj) };
            }
        };
        var obj={ width: 890, height: 400,
            dataModel: dataModel,
            colModel: colModel,
            pageModel: { rPP: 4, type: "local", rPPOptions: [1, 2, 5, 10, 20, 100]},
            title: "<b>Current Users</b>",
            flexHeight: true,                       
            paging: true,
            draggable: true,
            //resizable:true,           
            scrollModel: {autoFit:true},
           freezeCols: 0
        };
       
        var $grid=$("div#xml_grid").pqGrid(obj);                       
    });   
</script>
<div id="xml_grid" style="margin:auto;"></div>
   
    </div>
    </form>
</body>
</html>

***** xml file *****<?xml version="1.0" encoding="utf-8">
<Accounts>
   <Account>
      <Username>aa</Username>
      <Email>[email protected]</Email>
      <Role>Student</Role>
      <CreationDate>6/20/2016</CreationDate>
      <LastAccessed>6/30/2016</LastAccessed>
      <LoginCount>1</LoginCount>
      <Comment />
   </Account>
   <Account>
      <Username>steve</Username>
      <Email>[email protected]</Email>
      <Role>Student</Role>
      <CreationDate>6/29/2016 6:03 PM</CreationDate>
      <LastAccessed>6/29/2016 6:03 PM</LastAccessed>
      <LoginCount>1</LoginCount>
      <Comment />
   </Account>
   <Account>
      <Username>test</Username>
      <Email>[email protected]</Email>
      <Role>Student</Role>
      <CreationDate>6/30/2016 5:08 PM</CreationDate>
      <LastAccessed>6/30/2016 5:08 PM</LastAccessed>
      <LoginCount>1</LoginCount>
      <Comment />
   </Account>
   <Account>
      <Username>test1</Username>
      <Email>[email protected]</Email>
      <Role>Student</Role>
      <CreationDate>6/30/2016 4:47 PM</CreationDate>
      <LastAccessed>6/30/2016 4:47 PM</LastAccessed>
      <LoginCount>1</LoginCount>
      <Comment />
   </Account>
</Accounts>

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: grid display does not format correctly
« Reply #1 on: July 16, 2016, 09:43:21 pm »
From the screenshot, it looks like you are missing css files.

Recheck the path to css files and include pqgrid.ui.(min/dev).css file for Pro.

http://paramquery.com/pro/tutorial#topic-include

steveferg

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: grid display does not format correctly
« Reply #2 on: July 17, 2016, 12:23:59 am »
Putting in the pqgrid.ui.min.css cleared up the formatting but now it says my xml is invalid even though it was created with xmlwriter. I tried taking out all the \r\n and tabs but that didn't help. I even changed things like <Comment /> to <Comment> </Comment> and changed the first line to <?xml version="1.0" encoding="UTF-8"?> I also even took tried taking that line out, but it still does not like the xml file. Is there something in the xml that suddenly is not acceptable?

steveferg

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: grid display does not format correctly
« Reply #3 on: July 17, 2016, 11:34:27 am »
Found it!

Somehow I accidentally deleted a left bracket on one of the <Email> tags. Any error in the xml will cause the entire xml file to be flagged as invalid.