PDA

View Full Version : auto reload grid data strange error



0xception
11 May 2007, 3:43 PM
Hello, I'm a fairly light weight developer so please let me know if i'm doing something wrong....

Anyways i have a grid that i'm filling with an XMLReader and i would like to auto reload or refresh that data every 5 sec or so...

so i setup a update manager on the grid object and called startAutoRefresh(5,loadCalls); where loadCalls is a function that just reloads the data.Store object... however this returns a weird firebug error of


uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: javascript: eval(__firebugTemp__); :: anonymous :: line 1" data: no]

I'm not entirely sure what this is or why it's happening... if i hook the same function into a on click event then it works just fine.

here is my grid definition:



call = Ext.data.Record.create([
{name: 'CallerId', mapping: 'CallerId'},
{name: 'Status', mapping: 'Status'},
{name: 'Queue', mapping: 'Queue'}
]);

// create the Data Store
ds = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({url: 'modules/helpdesk.php?a=listCalls'}),

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
record: 'Call',
id: 'UniqueId',
}, call )
});

var cm = new Ext.grid.ColumnModel([
{header: "CallerId", width: 120, dataIndex: 'CallerId'},
{header: "Status", width: 180, dataIndex: 'Status'},
{header: "Queue", width: 115, dataIndex: 'Queue'}
]);

cm.defaultSortable = true;

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

var calls_mgr = Ext.get('grid-example').getUpdateManager();
calls_mgr.startAutoRefresh(5,function () { ds.reload(); });



i took out the loadCalls function here and just made it inline but neither way seems to work.

(by the way if you can't tell... this is basically a copy paste from the example grid :D )
any ideas?

jsakalos
11 May 2007, 4:15 PM
I have a hint (untested).

UpdateManager is bound to an element and it is primarily designed to update the element's content. Let's say you have a div (container) and you want to set the content of that div with data (html markup) from a server.

Now, in your code you get the UpdateManager of the grid's container and I guess this could be the source of the problem.

Maybe you could create an empty hidden div, get update manager of that div and start autorefresh.

Try, I hope this helps.

0xception
11 May 2007, 5:49 PM
welp thanks for the hint... that does seem to work in terms of it now updates the data store object and redraws the grid... however i'm still getting that error every 5 secs, which occurs at the end of the function right after the ds.reloads();

So i'm not sure if this is a Ext error or something in firebug...

0xception
12 May 2007, 12:05 AM
I ran across this forum post (http://extjs.com/forum/showthread.php?t=4392) and Animals solution seems to do the same work but without the errors... i'm still not sure why those errors appear, but if anyone else is interested in a solution that post seems to have it.

Animal
12 May 2007, 1:35 AM
My solution works because It's not using an UpdateManager.

Your solution uses UpdateManager which pulls a data String from a specified URL and puts it into the innerHTML of its Element. That's not what you want is it?

The URL will be undefined because you pass the result of a void function call as the URL parameter. So when the UpdateManager tells the XMLHttpRequest to open that URL, not surprisingly, it throws an error.

mohteshim
30 Jun 2007, 8:55 PM
can you kindly let me know what the solution was that animal proposed... as i am having the same problem and would like to use animal's solution

rgds,
Mo

mohteshim
30 Jun 2007, 10:26 PM
thanx it works....