PDA

View Full Version : Extjs with xhtml



Lorenxo
17 May 2010, 12:56 AM
Hello, I am doing a web application that must send or receive only xhtml/html, and I have to use it for my grid and other things.
Is it possible? Can I use xmlreader with xhtml? There is a way to pupulate a grid with xhtml?I have to transform xhtml to xml? Is That possible?
I have searched in this forum and in the web but I can't find something helpful.
Thanks

Condor
17 May 2010, 6:13 AM
Yes, you can use an XMLReader with XHTML.

But if you want your application to work on IE6 then you will have to set the Content-type of the XHTML to text/xml or application/xml.

Lorenxo
17 May 2010, 6:37 AM
Thank you, In a first time I tried to create an xhtml using a div and some h1 and h2 containing my data, I receive everything but I was not able to pupulate the grid.
After I have created an html table containing 2 field with my data, I reveived everything and the grid was populated, but there were a lot of white row before my data and after.
Do you know a better way to send data using xhtml?
Thanks

Condor
17 May 2010, 9:22 AM
You'll have to post some more info (XMLReader config + sample data).

Lorenxo
17 May 2010, 11:11 AM
This is my store and the ajax request:




var store = new Ext.data.Store({

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "libro" tag
record: 'tr',
id: 'th',
//totalRecords: '@total'
}, [
{name: 'titolo', mapping: 'th'},
{name: 'autore', mapping: 'td'},
])
});

//Ajax request with Post

Ext.Ajax.request({
url : AVAILABLEDOCSURL,
params : {
wanted: 'xmlbooklist',
},
method: 'POST',
success: function ( result, request ) {
Ext.MessageBox.alert('Document list correctly loaded from server', result.responseText);
store.loadData(result.responseText);
document.body.dolayout();
},
failure: function ( result, request) {
//Ext.MessageBox.alert('Failed', result.responseText);
Ext.MessageBox.alert('Failed', 'Unable to load book list from the server');
}
});





I use a servlet that create the xhtml, I use a table to contain my data in this way:



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Books</title>
</head>
<body>
<table>
<tr>
<th>title1</th>
<td>author1</td>
</tr>
<tr>
<th>title2</th>
<td>author2</td>
</tr>
<tr>
<th>titlek</th>
<td>authork</td>
</tr>
</table>
</body>
</html>

Like I have already said I am able to pupulate, but in the grid there are some blank row before and after my data.

Condor
17 May 2010, 10:17 PM
I'm amazed that this actually works!

It should be:

store.loadData(result.responseXML);

Lorenxo
19 May 2010, 12:59 PM
You were right,
Thanks Condor.