Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Saravana on Jul 30, 2007 11:15
open dhtmlx forum
dHtmlGrid

I have a xmlstring as well as xmldocument object in my servlet.
(1) How to load the serverside xmlstring/xmldocument object to the grid. I dont want to save any xml in client's machine. Can you give me an example?
(2) Also i want to save the xml in db through ajax from grid.
(3) How to set the properties of individual cell.(font color, size, font family etc) style attribute is available for row. But i want to set it for individual cell.
Answer posted by PierreL on Jul 31, 2007 13:27

Here is a simplest way to generate XML inline by generating javascript loadXMLString("<rows> ...") directly from jsp 

( notice you should have \" in javascript value , so should have \\\" in java generating javascript )

 mygrid.loadXMLString("<%
 out.print("<rows>");
 out.print("<head>");
 out.print("<column width=\\\"50\\\" type=\\\"ed\\\" align=\\\"center\\\"  sort=\\\"str\\\" id=\\\"SOLD\\\">sold</column>");
 out.print("<column width=\\\"140\\\" type=\\\"ed\\\" align=\\\"center\\\"  sort=\\\"str\\\" id=\\\"TITLE\\\">Title</column>");
 out.print("<column width=\\\"100\\\" type=\\\"ed\\\" align=\\\"center\\\"  sort=\\\"str\\\" id=\\\"AUTHOR\\\">Author</column>");
 out.print("<column width=\\\"80\\\" type=\\\"ed\\\" align=\\\"right\\\"  sort=\\\"int\\\" id=\\\"PRICE\\\">Price</column>");
 out.print("<column width=\\\"80\\\" type=\\\"ch\\\" align=\\\"center\\\"  sort=\\\"int\\\" id=\\\"STOCK\\\">available</column>");
 out.print("<column width=\\\"80\\\" type=\\\"ra\\\" align=\\\"center\\\"  sort=\\\"date\\\" id=\\\"BEST\\\">Best seller</column>");
 out.print("<column width=\\\"150\\\" type=\\\"ro\\\" align=\\\"center\\\"  sort=\\\"str\\\" id=\\\"DATEPUB\\\">Date </column>");
 
 out.print("</head>");
 // loop for lines of values
  String snb=request.getParameter("nb");
  if(snb == null ) snb= "100";
  int nb=new Integer(snb).intValue();
  for (int i=0;i<nb;i+=1){
    out.print("<row>");
    out.print("<cell>"+i%50+"</cell>");
    out.print("<cell>text for book "+new Integer(i)+"</cell>");
    out.print("<cell>author"+new Integer(i)+"</cell>");
    out.print("<cell>"+i*100+"."+i+"</cell>");
      out.print("<cell>"+i%2+"</cell>");
      out.print("<cell>"+(i+1)%3+"</cell>"); 
      out.print("<cell>"+((i%30)+1)+"/"+((i%12)+1)+"/"+(2000+i%10)+"</cell>"); 
      out.print("</row>");  
  }
    out.print("</rows>"); 
    // end generation of loadXMLString(datas,functionAfterLoad)
    out.print("\");");
 %>  

 

A better way is to use the loadXML syntax for the grid

mygrid.loadXML("myNewJSP.jsp");

and to furnish an independant jsp that generate only the previous string ( no need to escape twice) with surrounding

("<?xml version=\"1.0\" encoding=\"UTF-8\"?><data>

............

</data>");

( See java examples within download)

 

while myNewJSP.jsp just do

Answer posted by Darya (Support) on Dec 02, 2014 11:31

I hope this information will be enough for you. But you also can have a look at user interface component and menu tree.