PDA

View Full Version : grid xml



bjeenie
14 Jun 2007, 6:29 AM
hello,

i inserted ext-all.js to my webpage.

and i also hava a values.js javascript file where i get a list of values (output in XML) through AJAX.

so i have a xml-request.

I've seen in the demo's of ext that you can make a grid with an XML that you get from AJAX.

when i take a look at the demo i don't get how it has to work.

i have this javascript code:



function getResults()
{
var pars = 'actie=getResults&Persnr=' + strPersnr;

var myAjax = new Ajax.Request(
url,
{
method: 'post',
postBody: pars,
onComplete: setResults
});
}

function setResults(originalRequest)
{
// create the Data Store
var ds = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({originalRequest})

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'Item',
id: 'ASIN',
totalRecords: '@total'
}, [
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
{name: 'Author', mapping: 'ItemAttributes > Author'},
'Title', 'Manufacturer', 'ProductGroup'
])
});

var cm = new Ext.grid.ColumnModel([
{header: "Author", width: 120, dataIndex: 'naam'},
{header: "Title", width: 180, dataIndex: 'testnaam'},
{header: "Manufacturer", width: 115, dataIndex: 'score'},
{header: "Product Group", width: 100, dataIndex: 'datum'},
{header: "Product Group", width: 100, dataIndex: 'uur'}
]);
cm.defaultSortable = true;

// create the grid
var grid = new Ext.grid.Grid('example-grid', {
ds: ds,
cm: cm
});
grid.render();

ds.load();
}


but it gives this faults:
line 65: ":" is expected -->proxy: new Ext.data.HttpProxy({originalRequest})
line 10: "Ext" is not defined
line 34: object is expected.

What do i do wrong?

kind regards.
thomas

Animal
14 Jun 2007, 6:51 AM
but it gives this faults:
line 65: ":" is expected -->proxy: new Ext.data.HttpProxy({originalRequest})
line 10: "Ext" is not defined
line 34: object is expected.

What do i do wrong?

kind regards.
thomas

Read your code. It wants a ":", look what you have there. A ";"

Ext. Check with Firebug that the correct files are being loaded.

You do not have to make any Ajax requests to get the XML data. The Store (Using the HttpProxy configured with a URL) does all that for you.

See the example code.

Animal
14 Jun 2007, 6:53 AM
OK, it's just the font FF uses. You do not have a ";" where a ":" should be, it just looks like it!

Animal
14 Jun 2007, 6:55 AM
Right, now I can read it.

{OriginalRequest} is not valid javascript.

bjeenie
14 Jun 2007, 7:12 AM
yeah thanks

i changed it a bit,
and now i only get this "ext is not defined" error.

i only have this implemented:
<script src="js/ext-1.0.1/ext-all.js"></script>

and yes it is on that place.
do i need something else?

or do i have to define Ext?

bjeenie
14 Jun 2007, 7:25 AM
yeah don't answer previous.

it works now.

BUT, i still don't get my xml-data on the screen...
I do get the header info but that's it...

any thoughts?

tryanDLS
14 Jun 2007, 7:49 AM
Step thru the ds.load fn in Firebug to see what's happening. Use ext-all-debug.js instead, so you can read the code.

Animal
14 Jun 2007, 8:18 AM
The "dataIndex" property in the ColumnModel must map to a "name" of a field in the Record definition.

bjeenie
14 Jun 2007, 10:20 PM
thx it was this i forgot:

record: 'test',
id: 'score',
totalRecords: '@total'

Thanks!

ajaxE
17 Jun 2007, 7:21 PM
Hi,

I found the edit-grid.html in the ext-1.0.1 examples/grid directory doesn't work for IE 6. But it works fine for FF2.0. Any idea to make it working>

Thanks.

tryanDLS
18 Jun 2007, 8:19 AM
Hi,

I found the edit-grid.html in the ext-1.0.1 examples/grid directory doesn't work for IE 6. But it works fine for FF2.0. Any idea to make it working>

Thanks.
That example works correctly in IE6. If you have modified it, compare it to the original version in the zip to see what's changed.

ajaxE
19 Jun 2007, 8:30 PM
The example of edit-grid.html is not working in IE6. Is this a too simple question and no one cares?

Thanks.

ajaxE
19 Jun 2007, 8:36 PM
Thanks for your reply. I didn't change anything. I just simply copied it under my server. Do I need to change anything. The directory structure I copied seems exact same with what original file has. Therefore I didn't change anything.

The table header and frame show up correctly. Only the XML data is not loaded into the table.

Thanks.

tryanDLS
20 Jun 2007, 7:45 AM
Are you running it from a webserver? You can't just run from Explorer.