jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Exporting zip codes to XLS renders as date?
Tagged: datagrid
This topic contains 4 replies, has 2 voices, and was last updated by robrichard 12 years, 8 months ago.
-
Author
-
Hi guys! I just downloaded and used 2.5 and in the export function of the grid, when it exports a 5 digit zip code into Excel, the field displays as a date. I tried changing the cellformats to ‘n’, but then it puts the comma in the zip code like a regular number. Possible bug or is there a way to format it as a string so that it exports properly?
Thanks!
Hi robrichard,
Did you set the type property in the datafields definition? The type specifies the type of your field and for zip code, I suppose it should be ‘number’ or ‘string’.
Regards,
Peter SToevjQWidgets Team
http://www.jqwidgets.comThanks Peter. According to the documentation there are only two options: number and checkbox. I tried string as an option, thinking perhaps the docs were not updated with that option, but no luck. It still exports as a date (and all the same, regardless of the value of the zip code – 12/31/1969
Hi robrichard,
I don’t think that you understood me and I will try to explain again. You need to set the “type” property where you define the datafields array in the source object.
Example:
var source = { localdata: data, datatype: "array", datafields: [ { name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'available', type: 'bool' }, { name: 'date', type: 'date' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' } ] };
This is explained in the source object’s initialization in the API documentation and it is updated Today.
http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-api.htm
Here’s what the documentation says about datafields:
- datafields - array including the member names in your data source. The following are the allowed options in the datafield definition: name(required) - points to a field name in the data source.type - sets the field's type. The value could be: 'string', 'date', 'number' and 'bool'.map - sets the path to the field in the data source.Example: { name: 'CompanyName', map: 'm\\:properties>d\\:CompanyName' }id - determines the id of a record in a foreign collection which should match to the record's name in the source collection.text - determines the display field from the foreign collection..source - determines the foreign collection associated to the data field.
Regards,
Peter SToevjQWidgets Team
http://www.jqwidgets.comYep, completely lost what you were talking about. Thankfully your example proved useful, and the use of
type: 'string'
in the datafields collection indeed fixed the issue.
-
AuthorPosts
You must be logged in to reply to this topic.