Forum
11:00
30/08/2008
Hello, all,
I am a beginner to JQGrid, wich i am finding fantastic, however i have a difficulty wich i am at a loss on how to fix it.
I am trying to read a XML file into a grid. However if one of the records on any line uses an accented character (for instance é or á) the grid fails to display all lines, only the header is displayed.
Here is the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<results>
<NewDataSet>
<Table>
<CustomerID>ALFKI</CustomerID>
<CompanyName>Alfreds Futterkiste</CompanyName>
<ContactName>Maria Anders</ContactName>
<ContactTitle>Sales Representative</ContactTitle>
<Address>Obere Str. 57</Address>
<City>Berlin</City>
<PostalCode>12209</PostalCode>
<Country>Germany</Country>
<Phone>030-0074321</Phone>
<Fax>030-0076545</Fax>
</Table>
<Table>
<CustomerID>ANATR</CustomerID>
<CompanyName>Ana Trujillo Emparedados y helados</CompanyName>
<ContactName>Ana Trujillo</ContactName>
<ContactTitle>Owner</ContactTitle>
<Address>Avda. de la Constitucin 2222</Address>
<City>México D.F.</City>
<PostalCode>05021</PostalCode>
<Country>Mexico</Country>
<Phone>(5) 555-4729</Phone>
<Fax>(5) 555-3745</Fax>
</Table>
</NewDataSet>
</results>
The word México causes the grid lines with the data not to appear, only the header is shown. But if i replace it for Mexico then it works fine.
Now, in fact and since the encoding is UTF-8 the correct way it should be written is ME9xico but it still doesn't work.
I have consulted the documentation and some forum posts but have found nothing helpfull.
I'm posting the full code i am using for the web page and i apologise in advance if this is a simple question but i truly was unable to understand why this is happening.
Thanks in advance,
Mário
PS - Here is the full web page code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="listalerts.aspx.vb" Inherits="Default2"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<link rel="stylesheet" type="text/css" media="screen" href="themes/sand/grid.css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list19").jqGrid({
url: 'texte.xml',
datatype: "xml",
colNames:["Author","Title", "Price", "Published Date"],
colModel:[
{name:"CompanyName",index:"CompanyName",width:120, xmlmap:"CompanyName"},
{name:"Title",index:"Title", width:180,xmlmap:"Title"},
{name:"Price",index:"Manufacturer", width:100, align:"right",xmlmap:"Price", sorttype:"float"},
{name:"DatePub",index:"ProductGroup", width:130,xmlmap:"DatePub",sorttype:"date"}
],
height:250,
rowNum:10,
rowList:[10,20,30],
imgpath: 'themes/basic/images',
viewrecords: true,
loadonce: true,
xmlReader: {
root : "NewDataSet",
row: "Table",
repeatitems: false,
id: "CustomerID"
},
caption: "XML Mapping example"
});
});
</script>
<title>Untitled Page</title>
</head>
<body>
test
<form id="form1" runat="server">
<div>
<table id="list19" class="scroll" cellpadding="0" cellspacing="0"></table>
</script>
</div>
</form>
</body>
</html>
03:17
Moderators
30/10/2007
Hello,
This problem is not related to jqGrid and jQuery at all.
Also some notes.
1. You must sure that after the connection you have the
appropriate encoding. In PostgreSQL and MySQL I usually use
SET NAMES = utf8 command.
2. The database should be in UTF8
3. Before sending the data you must send the appropriate header
in PHP I use header function
header(”Content-type: text/xml;charset=utf-8″);
4. Also in xml you should set this
<?xml version=”1.0″ encoding=”utf-8″?>
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
17:19
30/08/2008
Hello Tony,
Thanks, for your feedback, it put me in the right track.
I'll just leave my findings for anyone that searches the forum for a similar issue.
In fact i was not generating a page via a server side scripting language such as PHP, i was going directly to a xml file. The problem was that the BOM was missing
http://unicode.org/faq/utf_bom.html#BOM
As soon as i opened and saved the file with an UTF-8 compliant editor it started working.
Thanks for your help!
Mário
Most Users Ever Online: 715
Currently Online:
25 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66