Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Lagnajeet Sahu on Mar 29, 2009 23:31
open dhtmlx forum
format for column

Hi,

I am using licensed version of dhmtlx treegrid v 2.1 with split mode. The treegrid is not created with xml. I am creating the treegrid from an array.

The headers are created using the setHeader function , where in i pass a comma separated string of header names. I want number and date formating for my columns. I tried few samples using xml loading , in which i can set formats like .,

<column type='dhxCalendar' width='63' sort='na' format='m/d/y'>
<column type='edn' width='72' sort='na' format='0.00' align='right'>

How can i set the formats with code , as I am not using xml loading.

I found 2 functions in the API doc.

setDateFormat(...) [Professional] - set mask for date formatting in cell
setNumberFormat(...) [Professional] - set mask for formatting numeric data ( works for [ed/ro]n excell only or oher cell types with suport for this method)

How can i use these 2 functions , give me a example / sample.

Is there any function similar to the above 2 to set the formats at the column level [ rember i am not using xml].



Answer posted by dhxSupport on Mar 30, 2009 05:55

If you are loading grid via javascript array, you can set number and date fromat only with API:

mygrid.setColTypes("dhxCalendar,end");

mygrid.setDateFormat("%m/%d/%Y"); // => 01/25/1980

mygrid.mygrid.setNumberFormat(1,"0,000.00",",","."); //1456.789 => 1,456.78

You can find more information here http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Cell_values_formating.html#grid_art_formatcells