jQWidgets Forums

jQuery UI Widgets Forums Grid export of numbers in cells won't work

This topic contains 7 replies, has 3 voices, and was last updated by  bigstoef 12 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • export of numbers in cells won't work #8641

    timo75
    Participant

    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?

    export of numbers in cells won't work #8643

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    export of numbers in cells won't work #8651

    timo75
    Participant

    No I did not.

    Where is that e.g. done in your online demo at http://jsfiddle.net/jqwidgets/6HRU8/ ?

    export of numbers in cells won't work #8653

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    export of numbers in cells won't work #8654

    timo75
    Participant

    I see. I’m jusing JSON data. After defining the type everything works fine.

    Thanks a lot,
    Timo

    export of numbers in cells won't work #15500

    bigstoef
    Member

    Hi 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?

    export of numbers in cells won't work #15501

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    export of numbers in cells won't work #15503

    bigstoef
    Member

    yes 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” 🙂

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.