Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Andreas Ruge on Aug 06, 2008 01:40
open dhtmlx forum
Call to mygrid.updateFromXML(XML); results in script error "Object doesn't support this property or method"...

Hi,

I'm using the free version of the grid in combination with the toolbar on one page. On loading the page I call the function mygrid.loadXML(XMLFile). The grid is display correctly with no problem. I have a button on the toolbar in to OnClick event of the button mygrid.updateFromXML(XMLFile) is called. After a time IE comes with a Script error "Object doesn't support this property or method" in line 559 in the index.php file. Funny as my index.php file (and result) have only 144 lines.

The xml file looks like bu with 1244 rows.
<?xml version="1.0" encoding="UTF-8" ?>
<rows>
<row id="4">
<cell />
<cell>800425</cell>
<cell>Goldmann</cell>
<cell>A. Bertram Chandler</cell>
<cell>Grimes reist in die Unendlichkeit</cell>
<cell>Abenteuer Randwelt 1</cell>
<cell>Deutsch</cell>
<cell>3-442-23756-4</cell>
<cell />
<cell>5.80 DM</cell>
<cell>undefined</cell>
<cell>SCIENCE FICTION</cell>
<cell />
<cell>2001-08-17</cell>
<cell>1988-09-01</cell>
</row>
<row id="1">
<cell />
<cell>800426</cell>
<cell>Goldmann</cell>
<cell>A. Bertram Chandler</cell>
<cell>Grimes auf El Dorado</cell>
<cell>Abenteuer Randwelt 2</cell>
<cell>Deutsch</cell>
<cell>3-442-23757-2</cell>
<cell />
<cell>5.80 DM</cell>
<cell>undefined</cell>
<cell>SCIENCE FICTION</cell>
<cell />
<cell>2001-08-17</cell>
<cell>1988-09-01</cell>
</row>
</rows>

the source looks like:
...
<script src="codebase/dhtmlxcommon.js" type="text/javascript"></script>
<script src="codebase/dhtmlxgrid.js" type="text/javascript"></script>
<script src="codebase/dhtmlxgridcell.js" type="text/javascript"></script>
<script src="codebase/ext/dhtmlxgrid_srnd.js" type="text/javascript"></script>
<script src="codebase/ext/dhtmlxgrid_filter.js" type="text/javascript"></script>
<script src="codebase/dhtmlxprotobar.js" language="JavaScript"></script>
<script src="codebase/dhtmlxtoolbar.js" language="JavaScript"></script>
...
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxtoolbar_xp.css">
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxgrid.css">
...
<body onLoad="doInitGrid();">

<div id="toolbarBox" style="width:100%;height:30"></div>
<div id="mygrid_container" style="height:100%;width:100%;"></div>

<script type="text/javascript">
var toolbar;
var mygrid;

function doInitGrid(){
gridQString = "booksxml.php";//save query string to global variable (see step 5 for details)
mygrid.loadXML(gridQString);
}     
    
function OnClickToolbar(ae,itemValue)
{
if (ae=="0_refresh"){
gridQString = "booksxml.php";
mygrid.updateFromXML(gridQString);
}
}    

mygrid = new dhtmlXGridObject("mygrid_container");
mygrid.setImagePath("codebase/imgs/");
mygrid.setEditable(false);
mygrid.setSkin("light");
mygrid.setHeader(",Barcode,Publisher,Author,Title,Series,Language,ISBN,EAN,Prize,Format,Type,Remark,Creation,Change");
mygrid.attachHeader("#rspan,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#select_filter,#text_filter,#text_filter,#numeric_filter,#select_filter,#select_filter,#rspan,#rspan,#rspan");
mygrid.setInitWidths("26,65,100,120,180,180,75,100,100,65,100,180,120,75,75");
mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro");
mygrid.setColAlign("center,left,left,left,left,left,left,left,left,right,left,left,left,left,left");
mygrid.setColSorting("server,server,server,server,server,server,server,server,server,server,server,server,server,server,server");
mygrid.attachEvent("onBeforeSorting",sortGridOnServer);
mygrid.init();
mygrid.enableSmartRendering(true);
mygrid.attachEvent("onRowDblClicked",onRowDblClicked);

toolbar = new dhtmlXToolbarObject("toolbarBox","100%","20","Books");
toolbar.loadXML(\"toolbar.xml\");
toolbar.setToolbarCSS("toolbar3","toolbarText3");
toolbar.setOnClickHandler(OnClickToolbar);
toolbar.showBar();
</script>
</body>
</html>

Answer posted by Support on Aug 06, 2008 03:23
Which version of grid you are using?
Issue can't be reconstructed with latest version. Latest dhtmlxgrid.js ( standard edition ) and sample attached to post. 
Attachments (2)
Answer posted on Aug 06, 2008 04:05

Yes your example is working correctly. But when I change the code like this I get the same error as on my app. I'm using v.1.6 build 80603 of the grid. Problem persists with the attached version of the grid.

//mygrid.attachEvent("onRowDblClicked",onRowDblClicked);

    mygrid.loadXML("500.xml");
</script>

<input type="button" name="some_name" value="update" onClick="mygrid.updateFromXML('500.xml');">

As I want to reload the xml (because the data in the database has changed), I'm loading the same XML again.

Answer posted by Support on Aug 06, 2008 08:20
Problem in IE confirmed and fixed
Fixed version of js file attached to post. 
Attachments (1)
Answer posted on Aug 06, 2008 23:46

Thank you. It now works... until you use a filter in the grid. Enter john in the filter for the author and hit Update. You wil get an error "this.rowsBuffer[...]" is null or not an object...

 

Answer posted by Support on Aug 07, 2008 03:11
It is not safe to update grid while it in filtered state
The only way is - unfilter grid, update dataset, filter grid back.
Answer posted on Aug 07, 2008 04:16
Thanks, but how do I do that with the internel filter? I can find that in the documentation. I only see functons to set the filterBy(...) witch is professional only. Thst is in itself not a problem, as I wil buy the complete suite today. An example would be nice.
Answer posted on Aug 07, 2008 05:24
Hi again, could you provide me the fix for the update also for the professional version? My registraton numer is 222146955.
Answer posted by Support on Aug 07, 2008 06:11
>>Thanks, but how do I do that with the internel filter? 
Please check 
    http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=3752&ssr=yes&s=filter%20delete%20row
The same approach can be used for update from XML ( please inform if its still unclear I will send some kind of sample )


>>Hi again, could you provide me the fix for the update also for the professional version
Sent by email. 
Answer posted on Aug 07, 2008 09:18

Sorry for being so persistent. But the fixed professional version I got with the mail was the not fixed version (beyond compare for the fixed and not fixed version revealed no changes at all ;-)

I fixed that myself now (apllying the same changes as in the free version). Now the update works the same as in the free version.

I also implemented the suggested defiltering before updating like:

if (ae=="0_refresh"){  
    mygrid.filterBy(0);
    mygrid.updateFromXML("booksxml.php");
    mygrid._srowsCol=mygrid._f_rowsBuffer=mygrid._srowsBuf=null;
    mygrid.filterByAll();
}

But still I'm getting the error "this.rowsBuffer[...]" is null or not an object...

Any other sugestion?

 

Answer posted by Support on Aug 08, 2008 02:22
Sample for updateFromXML sent by email.
Answer posted on Aug 08, 2008 03:23
It works, thanks for the help...