Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by jp on Nov 14, 2007 13:40
open dhtmlx forum
Tabbar and grid

Hi, i just downloaded the 1.2 version of tabbar component and i was trying to load a grid (dhtmlxTreeGrid_v14_Pro_70813) on one tab with the following settings:
...
<div id="tabs_detalle_consolidado" style="width:99%;height:420px"></div>
<script type="text/javascript">
tabbar=new dhtmlXTabBar("tabs_detalle_consolidado","top");
tabbar.setImagePath("images/");
tabbar.setSkinColors("#ffffff","#F4F3EE")
tabbar.loadXML("server/get_tabs.php");
</script>

This is get_tabs.php (it's php because later i want to load the tabs from DB):
<?php
header("Content-type:text/xml");
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
echo "<tabbar hrefmode='ajax-html'>";
echo "<row>";
echo "<tab id='t1' width='99%' selected='1' href='bg.php'>BG</tab>";
echo "</row>";
echo "</tabbar>";
?>

And the page that has the grid is bg.php:
...
<div id="div_grid_bg" style="clear:both; width:99%; height:350px;"></div>
<script type="text/javascript">
grid_detalle_consolidado = new dhtmlXGridObject('div_grid_bg');
grid_detalle_consolidado.imgURL = "images/";
grid_detalle_consolidado.enableDistributedParsing(true);
grid_detalle_consolidado.setSkin("xp");
grid_detalle_consolidado.attachEvent("onXLS",function(){....});
grid_detalle_consolidado.attachEvent("onXLE",function(){....});
grid_detalle_consolidado.init();
grid_detalle_consolidado.loadXML("server/get_detalle_consolidado.php?cache="+(new Date()).valueOf());
</script>

Everything loads great, but now i need a function in bg.php that has a for, i don't know why when i insert a for in the javascript code everything stops working, the tab stays empty and no error is shown by ie. I deleted the function with the for and started to work fine again, then i added this line "for(i=0;i<3;i++) alert(i);" at the beginning of the script and it stopped working again. Please help me i've been dealing with this for hours.

Thanks in advance
Answer posted on Nov 15, 2007 04:21
Problem caused by js code detection in dthmlxtabbar, while loading data in AJAX mode, the data can't be simple injected as innerHTML  ( in such case javascript in code will not be correctly processed ), so tabbar after loading data track all script zones and evaluate them.

      dhtmlXTabBar.prototype._resolveContent=function(id,val){
         var z=val.match(/<script[^>]*>([^<]+)<\/script>/g);

used RegExp is pretty simple and  it will fail if "<" char will be found in code

You can
    a) move such functionality in main html file and just call a function by name
or
    b) update described regexp so it will work for you code as well
         if you have single script tag per page it can be updated as
         var z=val.match(/<script[^>]*>([.\n]+)<\/script>/g);

   
Answer posted by jp on Nov 15, 2007 06:00

hi, thanks for your reply, i used the first solution, the second one didn't work.

Thanks