Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by anderson Peña on Feb 06, 2009 06:46
open dhtmlx forum
draganddrop dhtmlgridfromtable

hi, please i need your help

I have a problem when importing data from a table (HTML)! using dhtmlXGridFromTable i need drag and drop between tables! in the examples and documentation provided by you, only need to include the script dhtmlxgrid_drag.js
and use mygrid.enableDragAndDrop (true) "the examples are using XML" need help, i dont know if that propiety is only for data from XML and dont function in html table ..

thanks
Ap
Answer posted by Support on Feb 06, 2009 07:41
It can be used in case of loading from HTML table as well.
The tricky point that enableDragAndDrop need to be called before data parsed from table in grid, it can be done as 

<table class="dhtmlxGrid" name="mygrid" onbeforeinit="mygrid.enableDragAndDrop(true);"  ... 
Answer posted by AP on Feb 07, 2009 07:56

Thank you my friend!! you help me so much...

I decided do it because is more easy work when load data from xml...  i dont know XML and decided generate a PHP file and there create the XML file

<?php
function iniciar_xmlgrid($tabla,$archivo)
{
include"abrir_conexion_DB.php";
$query="SELECT * FROM $tabla";
$result=mssql_query($query,$link);

$xml='<?xml version="1.0" encoding="UTF-8"?>';
$xml.='<rows>';
while($fila = mssql_fetch_array($result))
 {
 $id_concepto=$fila[id_concepto];
 $n_concepto=  $fila[concepto];
 $concepto_mostrar=$fila[concepto_mostrar];
 $t_concepto=$fila[tipo_concepto];
$xml.='<row id="'; $xml.="$id_concepto"; $xml.='">';
$xml.='<cell>'; $xml.="$concepto_mostrar"; $xml.='</cell>';$xml.='</row>';
 }
$xml.='</rows>'; 
file_put_contents("$archivo.xml",$xml);
mssql_close($link);
}
?>

PD: My English is not so good because I am of venezuela (latino) 

thanks for all your answers..  

Answer posted by Support on Feb 10, 2009 08:33
The code which you are using is correct but the next things can be done

a) cell value may contain special chars , which can break XML syntax, to be safe you can change it as 

$xml.='<cell><![CDATA['; $xml.="$concepto_mostrar"; $xml.=']]></cell>';

b) you are using temp xml file for result saving, which may be correct in your case, but in most case data can be loaded directly from php stream. 

$xml.='</rows>'; 
//file_put_contents("$archivo.xml",$xml);
header("Content-type:text/xml");
echo $xml;

mssql_close($link);

and in js code use 

grid.load("some.php"); //some.php contain call of  iniciar_xmlgrid