Editor removes commas from strings

Editor removes commas from strings

dynasoftdynasoft Posts: 446Questions: 69Answers: 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: 446Questions: 69Answers: 3

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

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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: 446Questions: 69Answers: 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: 446Questions: 69Answers: 3

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

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 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: 446Questions: 69Answers: 3

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

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 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.