Webix stringifies number keys for the select datatable editor

edited January 23 in Technical questions

Use case: calling a GraphQL API, which is specific about numbers, and expects numbers, not strings, in the JSON request. I have a select with number keys.

Demo: https://snippet.webix.com/c7lkz9wp

In the save.update method, we could convert the string to Number, but Webix not stringify numeric keys in the first place, or are there good reasons to always stringify numeric keys? Or is there some limitation like no 0s for ids?

Tagged:

Comments

  • edited January 30

    There are 2 problems here

    a) native js code issue. The keys of structure are always string, while you are using numbers, js code converts them silently to strings

    for (var key in { 3:"a" }) console.log(typeof key);
    will return "string"

    b) while Webix preserves data types, the handling of "id" is a bit different, its value is always converted to string

    Workaround

    You can add a scheme for the widget, which will set correct data type after edit operation

    Please check https://snippet.webix.com/2cpspxg2

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion