glide-data-grid icon indicating copy to clipboard operation
glide-data-grid copied to clipboard

Number cell with BigInt support

Open lukasmasuch opened this issue 1 year ago • 5 comments

The current version of the number cell only supports normal Numbers but not BigInt numbers (> 2^53). Two potential solutions would be to:

  1. Enable the native number-cell to handle BigInt values in addition to Number values.
  2. Add a dedicate big-int cell to the cells package.

lukasmasuch avatar Dec 29 '23 14:12 lukasmasuch

I think option 1 is the way to go if react number format supports it. Have you a usecase for bigint data?

jassmith avatar Dec 29 '23 18:12 jassmith

yeah, users have run into this a couple of times mostly related to columns that contain numerical IDs. And timestamps and time durations are sometimes represented in nanoseconds... which can easily overflow Number

lukasmasuch avatar Dec 29 '23 21:12 lukasmasuch

It looks like to make this possible we would need to swap out the editor implementation. react-number-format does not support this.

jassmith avatar Jan 02 '24 15:01 jassmith

I think react-number-format should be fine with handling larger numbers. E.g. 9007199254740992 is the highest supported value for Number without losing precision. In this demo, if you go higher the floatValue will lose precision but the string value will show the correct number:

https://github.com/glideapps/glide-data-grid/assets/2852129/5c33642e-e1d8-43d2-853a-9cebaadefabc

This means, that we would need to handle the value as a string for the react-number-format input field if the cell data is a bigint.

lukasmasuch avatar Jan 02 '24 16:01 lukasmasuch

Oh very nice. Okay Im on board with this.

jassmith avatar Jan 02 '24 18:01 jassmith