jQWidgets Forums
jQuery UI Widgets › Forums › Grid › export of numbers in cells won't work
Tagged: export to excel, jquery grid, jqxgrid
This topic contains 7 replies, has 3 voices, and was last updated by bigstoef 12 years, 3 months ago.
-
Author
-
I have a grid with plain numbers (just record IDs) in some colums (1 to 5 digits).
In the exported CSV all numbers are converted to “1/1/1970”. Seems like some kind of date function is involved during export(?).
Am I missing something?
Hi timo75,
Did you miss to set the ‘type’ field when you defined the datafields array in the source object’s initialization? The type can be ‘number’, ‘string’, ‘date’ or ‘bool’.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comNo I did not.
Where is that e.g. done in your online demo at http://jsfiddle.net/jqwidgets/6HRU8/ ?
Hi timo75,
The demo uses local data where Quantity and Price are Numbers i.e 3.4 not “3.4”. The dates are Date objects, not “1/2/2005” or something like that and etc. For any data type like ‘json’, ‘xml’, ‘tsv’, ‘csv’, you have to define ‘type’ in the datafields array definition.
Below is a sample definition of a source object from this help topic jquery-grid-datasources.htm”>.
var source ={ datatype: "xml", datafields: [ { name: 'ShippedDate', map: 'm\\:properties>d\\:ShippedDate', type: 'date' }, { name: 'Freight', map: 'm\\:properties>d\\:Freight', type: 'float' }, { name: 'ShipName', map: 'm\\:properties>d\\:ShipName' }, { name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress' }, { name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity' }, { name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry' } ], root: "entry", record: "content", id: 'm\\:properties>d\\:OrderID', url: url, sortcolumn: 'ShipName', sortdirection: 'asc'};
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI see. I’m jusing JSON data. After defining the type everything works fine.
Thanks a lot,
TimoHi im using json and set a type :
{ text: ‘Contact Persoon’, datafield: ‘cp’, width: 100, type: ‘string’ },
i also tried number and float but they all have the same result “1/1/1970”
anything else i should set or try?
Hi bigstoef,
The type should be set to the “datafield”, not to the column. Please, see the datafields array definition in my previous post and the Export sample available online.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comyes thnx that did it, these allnighters are messing with my logic. thanks for the quick replies funny detail my last name is “hoog stoevenbelt” yours is “stoev”
-
AuthorPosts
You must be logged in to reply to this topic.