Code Monkey home page Code Monkey logo

Comments (4)

Holt59 avatar Holt59 commented on August 19, 2024

Hi,

The timestamp was converted to a float value because parseFloat('2015-08-25') does not return a NaN value. Since this is not expected behaviour and I was a bit upset with type inference in the current version, I created a new branch for testing (https://github.com/Holt59/datatable/tree/fix-datatype) in which:

  1. Non numeric values should not be converted to float (stronger inference)
  2. You could specify dataTypes option to force type conversion:
var dt = new DataTable ('table-id', {
    dataTypes: ['int', false, 'date', 'float', function (x) { return MyClass (x) ; }]
}) ;

Currently supported values are:

  1. int, float, double - parseInt or parseFloat
  2. false, string, str - No conversion (function (x) { return (x) } ;)
  3. date, datetime - Convert to Date object (function (x) { return new Date (x) ; })

You can also specify a function that will be used as a converter.

*Note: * I did not test this very intensively, so feel free to tell me if you have trouble using it!

from datatable.

ronsavage avatar ronsavage commented on August 19, 2024

Thanx for the reply. I see now the rendering of my text hid the spans, so here it is, spread out:
< span >$timestamp< /span >.
Le'ts see if that works in this situation (it worked in my code). Yes! Now for my reply.....
OK. As for specifying the dataTypes. I wanted to use that option, but could not understand the syntax. Does the array have 1 entry per column? If so, it's suit my purposes. I did try true and false, but they did not stop conversion, so I was confused. This makes me think I should try with a false in every element to stop all conversion, which is appropriate in my case.
Sigh: No, I have 9 columns and adding
'dataTypes': [false, false, false, false, false, false, false, false, false],
did not stop truncation. Now trying 9 of 'string'... Nope. Trying 9 of 'str'... Nope. Truncation is ruthless.
No matter. My span trick works :-).

from datatable.

Holt59 avatar Holt59 commented on August 19, 2024

Did you try using the version under fix-datatype branch? There is no dataTypes option in the master branch. For the dataTypes option you can either specify:

  • One value per column (see my last post)
  • false - No conversion at all
  • true - Auto conversion (behavior of the previous version)

If you don't want to use the fix-datatype branch you can try setting the old forceStrings option to true:

var dt = new DataTable ('table-id', {
    forceStrings: true
}) ;
// Same as (with the correct branch)
var dt = new DataTable ('table-id', {
    dataTypes: false
}) ;

This will prevent any kind of conversion (it will even override dataTypes option).

from datatable.

ronsavage avatar ronsavage commented on August 19, 2024

Hi Mikaël

On 26/08/15 17:26, Mikaël Capelle wrote:

Did you try using the version under |fix-datatype| branch? There is no

No, sorry. I should have made that clear.

|dataTypes| option in the |master| branch. For the |dataTypes| option
you can either specify:

  • One value per column (see my last post)
  • |false| | |'str'| | |'string'| No conversion at all
  • |true| Auto conversion (behavior of the previous version)

OK! I was clearly using the wrong syntax.

If you don't want to use the |fix-datatype| branch you can try setting
the old |forceStrings| option to |true|:

var dt= new DataTable ('table-id', {
forceStrings: true
}) ;

This will prevent any kind of conversion (it will even override
|dataTypes| option).

You're right. That works.

So you can make my issue as not-a-bug.

Thanx for the replies.

Ron Savage - savage.net.au

from datatable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.