Editor removes commas from strings

Editor removes commas from strings

dynasoftdynasoft Posts: 422Questions: 67Answers: 3

When these are made up of numbers, eg: 123,147 becomes 123147 in the db and in a datatable after create.

I do not have any method or js function that removes them in my code. Please advise if this is by design or am I missing something? Can't these commas be escaped by editor? I could add some checks in preSubmit and escape these and other char's but to have to do this for all the editor fields I have now in my project would be a pain.

This question has an accepted answers - jump to answer

Answers

  • dynasoftdynasoft Posts: 422Questions: 67Answers: 3

    I need to add the underlying table field has a string data type

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @dynasoft ,

    If the field is numeric, it would be best to store it without the comma in the DB so you can perform numeric operations, such as sorting. If you need it, it would be best to define the field in Editor as a string, then the entire syntax will be preserved.

    Cheers,

    Colin

  • dynasoftdynasoft Posts: 422Questions: 67Answers: 3

    Hi

    Thanks. I followed whats on https://editor.datatables.net/reference/option/fields.type but get error 'Uncaught Error adding field - unknown field type string'. Kindly advise.

            var editor = new $.fn.dataTable.Editor({
    
                ajax: {
                    url: '/CustomerSNs/CRUDCustomerSNs/',
                    data: {
                        intContTpe: intContTpe1,
                        lngContIdx: lngContIdx1,
                        lngItemIdx: lngItemIdx1
                    },
                    type: 'POST',
                    async: true,
                    cache: false
                },
                table: '#tblDataTable',
                template: '#EditorForm',
                fields: [ 
                    {
                        label: '@(lblo.lblExcludedNumbers)**:',
                        name: 'CustomerVoiceCLI.RangeExcludedNumbers',
                        type: 'string'
                    }
                ],
                i18n: {...}
            });
    
  • dynasoftdynasoft Posts: 422Questions: 67Answers: 3

    The field should be a string. It will hold comma separated values, some values can be numeric.

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin

    It looks like a bug I'm afraid. I've just managed to reproduce that here. I'll dig into it and post back here when done.

    Allan

  • dynasoftdynasoft Posts: 422Questions: 67Answers: 3

    Thought so as this only occurs when the data with the commas is numeric

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin
    Answer ✓

    Commit here for the fix. I'm going to tag and release Editor 1.9.2 this Friday with that fix.

    Allan

This discussion has been closed.