Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by MiB on Dec 17, 2008 12:07
open dhtmlx forum
enableDragAndDrop(true)

hi

I have the follwoing code what doesnt work. I would like to move the table of row. thx!

<script type="text/javascript" src="js/dhtmlXCommon.js"></script>
<script type="text/javascript" src="js/dhtmlXGrid.js"></script>
<script type="text/javascript" src="js/dhtmlXGridCell.js"></script>
<SCRIPT type="text/javascript">
if (navigator.appVersion.indexOf("MSIE")!=-1){
dhtmlxEvent(window,"load",function(){

//flashgallery.enableAutoHeight(true);
flashgallery.setColWidth("0", "80");
flashgallery.setColWidth("1", "320");
flashgallery.setColWidth("2", "80");
flashgallery.setEditable(false);
flashgallery.setColTypes("ro,ro,ro");
flashgallery.setSkin("modern");
flashgallery.enableDragAndDrop(true);
});
};
</SCRIPT>
<script type="text/javascript" src="js/dhtmlXGrid_start.js"></script>
<script type="text/javascript" src="js/dhtmlXGrid_excell_link.js"></script>
<script type="text/javascript" src="js/dhtmlXGrid_drag.js"></script>
<SCRIPT type="text/javascript">
dhtmlxEvent(window,"load",function(){
flashgallery.setColWidth("0", "80");
flashgallery.setColWidth("1", "320");
flashgallery.setColWidth("2", "80");
flashgallery.setEditable(false);
flashgallery.setColTypes("ro,ro,ro");
flashgallery.setSkin("modern");
flashgallery.enableDragAndDrop(true);

});
</SCRIPT>

<table style="width: 480px;" gridHeight="auto" class="dhtmlxGrid" name="flashgallery" cellspacing="0" cellpadding="0" imgpath="imgs/" evenrow="even" unevenrow="uneven">
<thead>
<tr>
<th>Sor</th><th>Név</th><th>Törlés</th>
</tr>
</thead>
<tbody>
<?php

$QS = "SELECT * FROM subgalleries WHERE oid = ".$gid." ORDER by name ASC";
mysql_query("SET NAMES 'utf8'");
$result = mysql_query($QS) or die(mysql_error()."query error");
$i=1;
while ($sor = mysql_fetch_assoc($result)) {
echo('<tr>');
echo ('<td>'.$i.'</td>');
echo ('<td><a href="edit2.php?id='.$sor['id'].'&kategoria='.$kategoria.'" title="Szerkesztés">'.$sor['name'].'</a></td>');
echo ('<td><a href="JavaScript:Delete('.$sor['id'].','.$gid.');" class="del" title="Törlés">X</a></td>');
//echo ('<td></td>');
echo('</tr>');
$i++;
}
?>
</tbody>
</table>
Answer posted by Support on Dec 18, 2008 02:15
a) setColWidth - with command will affect column only if it already was rendered, for setting initial width you need to use
      grid.setInitWidths("80,320,80");
b) usage of onload event is not reliable, different browsers uses different order of onload function calls, so the code may start when grid not initialized yet. 
c) d-n-d mode must be enabled before data loading


<table style="width: 480px;" gridHeight="auto" class="dhtmlxGrid" name="flashgallery" oninit="gr_init_2()" onbeforeinit="gr_init_1()" ...

<script>
function gr_init_1(){
        flashgallery.enableDragAndDrop(true); 
}
function gr_init_2(){
       flashgallery.setColWidth("0", "80"); 
       flashgallery.setColWidth("1", "320"); 
       flashgallery.setColWidth("2", "80"); 
       flashgallery.setEditable(false); 
       flashgallery.setColTypes("ro,ro,ro"); 
       flashgallery.setSkin("modern"); 
}
</script>