Check documentation for the latest version 6.0 of dhtmlxSuite Serializing Data to XML,CSV DHTMLX Docs

Serializing Data to XML,CSV

XML

To serialize dhtmlxGrid data into an XML string, use the serialize method:

var myXmlString = mygrid.serialize();

Related sample:  Sample without title: dhtmlxGrid/samples/17_serialization/01_pro_serialize.html


Configuration methods and properties for XML serialization:

xml.s_row

sets a custom name for row tags

mygrid.xml.s_row="myrowtag";

xml.s_cell

sets a custom name for cell tags

mygrid.xml.s_cell="mycelltag";

xml.row_attrs.push

allows you to include custom row attributes to serialization

mygrid.setRowAttribute("row3","custom1","data");
...
mygrid.xml.row_attrs.push("custom1");

xml.cell_attrs.push

allows you to include custom cell attributes to serialization

mygrid.cells(i,j).setAttribute("custom2","data");
...
mygrid.xml.cell_attrs.push("custom2");

setSerializationLevel (PRO version)

specifies whether you should:

  • serialize user data or not,
  • serialize 'selected' attribute for the rows tags,
  • serialize grid structure info,
  • serialize the 'changed' attribute for the cells tags,
  • include just changed rows to serialization,
  • serialize cell values as CDATA sections
mygrid.setSerializationLevel(true,false,true,false,true,true);

setSerializableColumns (PRO version)

sets columns that will be included to serialization

mygrid.setSerializableColumns("true,false,false,true,false,false,false");

enableMathSerialization (PRO version)

enables serialization formulas as mathematical expressions not data values

mygrid.enableMathSerialization(true);

Related sample:  Sample without title: dhtmlxGrid/samples/17_serialization/01_pro_serialize.html

CSV

To serialize dhtmlxGrid data into a CSV string, use the serializeToCSV method:

var myCSVString = mygrid.serializeToCSV();

Related sample:  Import/export from/to CSV


CSV serialization related methods:

setCSVDelimiter

sets the CSV delimeter. By default, ','(comma)

mygrid.setCSVDelimiter("\t");

enableCSVAutoID (PRO version)

allows you to autogenerate IDs for rows while loading a grid from a CSV string

mygrid.enableCSVAutoID(true);

enableCSVHeader (PRO version)

'says' to recognize the first row in the CSV string as the header

mygrid.enableCSVAutoID(true);

submitSerialization

'says' to include the serialized grid as a part of form submit policy

mygrid.submitSerialization(true);

Related sample:  Import/export from/to CSV

Back to top