jQWidgets Forums

jQuery UI Widgets Forums Grid Problem with $.jqx.dataFormat.formatdate() with culture

This topic contains 5 replies, has 3 voices, and was last updated by  Peter Stoev 8 years, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • Nicolas
    Participant

    Hi!

    I have a cellrenderer function in my grid, in which I’m using this function :

    $.jqx.dataFormat.formatdate(value, cellformat, culture).

    But often, the function refuse to apply the culture, and return the string in the default culture. When this does happen, all the column is affected (but not all the grid).

    Here a example of data I use :

    value = Fri Aug 05 1988 14:59:00 GMT-0400 (EDT)

    culture = {“decimalseparator”:”,”,”thousandsseparator”:”.”,”days”:{“names”:[“Sonntag”,”Montag”,”Dienstag”,”Mittwoch”,”Donnerstag”,”Freitag”,”Samstag”],”namesAbbr”:[“So”,”Mo”,”Di”,”Mi”,”Do”,”Fr”,”Sa”],”namesShort”:[“So”,”Mo”,”Di”,”Mi”,”Do”,”Fr”,”Sa”]},”months”:{“names”:[“Januar”,”Februar”,”März”,”April”,”Mai”,”Juni”,”Juli”,”August”,”September”,”Oktober”,”November”,”Dezember”,””],”namesAbbr”:[“Jan”,”Feb”,”Mrz”,”Apr”,”Mai”,”Jun”,”Jul”,”Aug”,”Sep”,”Okt”,”Nov”,”Dez”,””]}}

    If I use the following cellformat, sometime it works, and sometimes it don’t (I didn’t find a way to reproduce everytime)!
    “dddd, d. MMMM yyyy”

    And if I use this one, it doesn’t want to show the “/” characters as long as I specify the culture (otherwise it works) :
    “dd/MM/yyyy HH:mm”

    So in conclusion, I feel that this function is really buggy when you specify a culture. And it is terribly hard to debug since it’s doesn’t return an error, but the default format instead. Can you take a look on this? Thank you!


    Peter Stoev
    Keymaster

    Hi Nicolas,

    The API that you use is not documented and I suppose that you saw it from some old post in the Forum.

    To see how dataAdapter’s formatting works, check the jqxdataAdapter demos available online.

    In addition, “cellsformat” works with the built-in rendering of jqxGrid and will not with customized rendering done by setting the “cellsrenderer” callback which overrides the rendering of jqxGrid cells.

    The jqxDataAdapter’s formatDate function works as expected with or without custom Culture.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    Nicolas
    Participant

    Hi,

    I can’t remember where I found this code. But my problem is that I need to use a different culture for each columns. So this is why I don’t use the cellsformat in my columns object, and I use cellsrenderer instead.

    In the last example of the dataAdapter, I found this code :
    dataAdapter.formatDate(record.date, ‘D’, localizationObject)

    What is the best way to accomplish what I want to do? Is it to write my custom cellsrenderer and to use this function in it? Or is there an easier way to get every column a different culture.

    Thank you for your time!


    Nicolas
    Participant

    Ok, I just found that my culture needs to define what is “/” and “:”, or it won’t show it. I would like to suggest to change this behavior : if the culture doesn’t have those two definitions, it should write it down in the response, like any other characters, instead of hidding it. Moreover, I think that those parameters don’t really make sense : it is the responsibility of the cellformat to define what character is separating values, not the culture.

    For my other problem, I’ll see if dataAdapter.formatDate() seems to solve it.

    Regards


    Beg
    Participant

    I’ve encountered same problem as mentioned above – I need different formating of 2 columns with 2 different locales. To achive that, I use cellrenderer:

    if ($.jqx.dataFormat.isDate(value)) {
        formattedValue = $.jqx.dataFormat.formatdate(value, column.cellsformat, Globalize.culture(localeString).calendar);
    }

    and that sometimes worked, sometimes didn’t.

    After debugging minified code of dataAdapter, I’ve found the reason – the function uses cache (this.datescache), but that cache is not checked against culture (the 3rd param). So when script format some date in one languge and then you try to format the same date (using same format string) in different language, cached value is used instead and wrong locale-formatted string is returned. Solution should be easy – use culture.name as another part of cacheId.


    Peter Stoev
    Keymaster

    Thank you for the information.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.