Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    13.0 regression: SpinnerItem Custom Editor fails when dealing with float numbers

    Hi,

    I have a ListGrid with a customer editor component for one of the cells (2nd cell). When the value of that cell is decimal, clicking on the edit icon or double-clicking on the cell to initiate edit results in JavaScript errors.
    In fact, values like this: 150 or even 150.0 work just fine. But when the original value from the data source is 150.1 or 150.11, etc, editing fails with the JavaScript error.

    This definitely used to work with SmartClient 11.1 Pro version. The problem started happening only when I upgraded to 13.0 Pro.

    SmartClient_v130p_2023-08-12_Pro
    Reproduced on Chrome and FF.

    Adding parseFloat(), changing column or editor type to "number" or "float" doesn't help.
    It fails even when changed() method is empty and change() method is removed.

    Here is the code.

    Code:
    isc.ListGrid.create({
        ID:"epSumDB",
         width:360, height:274, showEmptyMessage:false,
        canEdit:true,
        editByCell:true,
        selectionType:"single",
        showRollOverCanvas:true,
        showRollUnderCanvas:false,
        rollOverCanvasConstructor:isc.HLayout,
        rollOverCanvasProperties:{
            snapTo:"C",
           height:20, width:55,
            members:[
                {
                   _constructor:"Button", icon:"pencil_editing.png",
                  click: "epSumDB.startEditing(epSumDB.getRowNum(this.parentElement.record), 2)",
                  height:20, width:27
                 }
            ]
        },
        fields: [
            {name:"id", showIf:"false"},
            {name:"lng", title:"Original Value", canSort: false, width:68, canEdit:false},
            {name:"lngE", title:"Change Value", type:"number", width:64, showHover:true, hoverHTML:"return 'Change value'"},
            {name:"sum", title:"Sum", width: 66, canEdit:false},
            {name:"rval",  title: "R", width: 18, align: "center", formatCellValue: "(value<0?'R':'')", canEdit:false}
        ]
        ,hoverWidth:100
        ,getEditorProperties:function(editField, editedRecord, rowNum){
            console.log("getEditorProperties() editField.name="+editField.name+"; rowNum="+rowNum);
            if(editField.name=="lngE"){
                var item = {
                   editorType:"SpinnerItem", minValue:0.0, maxValue:360.0, step:1.0, //type:"float",
                   change:function(form,item,value){
                            epSumDB.setEditValue(rowNum,1.0,value);
                    },
                    changed:function(form,item,value){
                        epSumDB.setEditValue(rowNum,1.0,parseFloat(value));
                        console.log("getEditorProperties.changed() value="+value);
                        var cRec = epSumDB.getEditedRecord(rowNum);
                        if(cRec.id<13) refreshPane(2, cRec.id, cRec.lngE);
                    }
                };
                return item;
            }
            return null;
        }
        ,cellContextClick: "console.log('irrelevant')"
    });

    Error on Chrome:
    ISC_Core.js:2641 Uncaught TypeError: _1.toFixed is not a function
    at _3.isc_SpinnerItem__defaultGetNextValue [as $118d] (ISC_Forms.js:3330:57)
    at _3.isc_SpinnerItem_getNextValue [as getNextValue] (ISC_Forms.js:3328:88)
    at _3.isc_SpinnerItem_setValue [as setValue] (ISC_Forms.js:3343:48)
    at _3.isc_DynamicForm_setItemValues [as setItemValues] (ISC_Forms.js:616:333)
    at _3.isc_DynamicForm_setValues [as setValues] (ISC_Forms.js:493:38)
    at _3.isc_ListGrid_makeEditForm [as makeEditForm] (ISC_Grids.js:2266:160)
    at _3.isc_ListGrid_showInlineEditor [as showInlineEditor] (ISC_Grids.js:2202:22)
    at _3.isc_ListGrid__startEditing [as $31u] (ISC_Grids.js:2189:6)
    at _3.isc_ListGrid_startEditing [as startEditing] (ISC_Grids.js:2166:110)
    at _3.eval [as click] (eval at isc__makeFunction (ISC_Core.js:91:1135), <anonymous>:3:16)
    at _3.isc_StatefulCanvas_handleActivate [as handleActivate] (ISC_Foundation.js:241:108)
    at _3.isc_StatefulCanvas_handleClick [as handleClick] (ISC_Foundation.js:242:13)
    at _3.isc_c_EventHandler_bubbleEvent [as bubbleEvent] (ISC_Core.js:2542:89)
    at _3.isc_c_EventHandler_handleClick [as handleClick] (ISC_Core.js:2350:50)
    at _3.isc_c_EventHandler__handleMouseUp [as $k5] (ISC_Core.js:2332:11)
    at _3.isc_c_EventHandler_handleMouseUp [as handleMouseUp] (ISC_Core.js:2323:57)
    at _3.isc_c_EventHandler_dispatch [as dispatch] (ISC_Core.js:2641:122)
    at HTMLDocument.eval (eval at isc__makeFunction (ISC_Core.js:91:1135), <anonymous>:3:123)

    Error on FF:
    Uncaught TypeError: _1.toFixed is not a function
    isc_SpinnerItem__defaultGetNextValue https://localhost:8443/astro/isomorp..._Forms.js:3330

    isc_SpinnerItem_getNextValue https://localhost:8443/astro/isomorp..._Forms.js:3328

    isc_SpinnerItem_setValue https://localhost:8443/astro/isomorp..._Forms.js:3343

    isc_DynamicForm_setItemValues https://localhost:8443/astro/isomorp...C_Forms.js:616

    isc_DynamicForm_setValues https://localhost:8443/astro/isomorp...C_Forms.js:493

    isc_ListGrid_makeEditForm https://localhost:8443/astro/isomorp..._Grids.js:2266

    isc_ListGrid_showInlineEditor https://localhost:8443/astro/isomorp..._Grids.js:2202

    isc_ListGrid__startEditing https://localhost:8443/astro/isomorp..._Grids.js:2189

    isc_ListGrid_startEditing https://localhost:8443/astro/isomorp..._Grids.js:2166

    anonymous https://localhost:8443/astro/isomorp...es/ISC_Core.js line 91 > Function:3

    isc_StatefulCanvas_handleActivate https://localhost:8443/astro/isomorp...ndation.js:241

    isc_StatefulCanvas_handleClick https://localhost:8443/astro/isomorp...ndation.js:242

    isc_c_EventHandler_bubbleEvent https://localhost:8443/astro/isomorp...C_Core.js:2542

    isc_c_EventHandler_handleClick https://localhost:8443/astro/isomorp...C_Core.js:2350

    isc_c_EventHandler__handleMouseUp https://localhost:8443/astro/isomorp...C_Core.js:2332

    isc_c_EventHandler_handleMouseUp https://localhost:8443/astro/isomorp...C_Core.js:2323

    isc_c_EventHandler_dispatch https://localhost:8443/astro/isomorp...C_Core.js:2641

    anonymous https://localhost:8443/astro/isomorp...es/ISC_Core.js line 91 > Function:3

    isc_c_EventHandler_captureEvent https://localhost:8443/astro/isomorp...C_Core.js:2644

    isc_c_EventHandler_captureEvents https://localhost:8443/astro/isomorp...C_Core.js:2649

    <anonymous> https://localhost:8443/astro/isomorp...C_Core.js:2790




    Thank you.
    gene
    Last edited by genev; 15 Sep 2023, 14:08.

    #2
    Hi Gene,

    Is this meant to be standalone code to reproduce a problem? You mention a DataSource, but you didn't provide one, and you mention that the initial state of the data seems to be involved, but you didn't provide data.

    Also, it's not clear why you would call setEditValue() in the midst of a change() event. That's not a valid time to call setEditValue(), and it seems like it might be intended to establish an initial value, which is more something to do in rowEditorEnter or by passing values to startEditingNew().

    Overall though, aside from these usage issues, what appears to be happening is pretty simple: the field is declared as type:"number" and the actual field value looks like it may be a String (it lacks normal Number APIs). But without seeing the data, we can't confirm that.

    Comment


      #3
      Thank you for getting back to me.

      I'm simply using setData([]) to populate the table. This particular value is always a decimal number. If I change back-end implementation to send integers, it works. It also works for .0 decimals but any digit other than 0 after the decimal point now causes this issue.

      I tried doing parseFloat() as the first line and that didn't help.

      Commenting out the entire change() method doesn't help.

      Commenting out setEditValue() call doesn't help either. The error is exactly the same. //epSumDB.setEditValue(rowNum,1.0,parseFloat(value));
      In fact, even if I leave the changed method body completely empty, I'm still getting this error.

      This code still fails:
      Code:
      ,getEditorProperties:function(editField, editedRecord, rowNum){
              console.log("getEditorProperties() editField.name="+editField.name+"; rowNum="+rowNum);
              if(editField.name=="lngE"){
                  var item = { editorType:"SpinnerItem", type:"float", minValue:0.0, maxValue:360.0, step:1.0, //it fails without type:"float" and with or without specifying min/max Values and step as decimals or integers.
                      changed : function(form, item, value){
      
                      }
                  };
                  return item;
              }
              return null;
          }
      The field declaration as "number" was just my attempt to workaround the problem. Originally, I didn't have any type declaration at all. I tried "number" and "float" and that didn't help. Similarly, I didn't use the type:"float" declaration for the SpinnerItem originally, but it fails with and without it.

      {name:"lngE", title:"Change Value", width:64, showHover:true, hoverHTML:"return 'Change value'"}, //that was the original field declaration that worked in 11.1. It doesn't in 13.0.

      And the main issue is that the original code used to work in 11.1 Pro, I didn't change anything on the back or front end, I simply upgraded to 13.0 Pro and it stopped working.


      Thanks,
      gene

      Comment


        #4
        Hi Gene, if you can enhance your test case to show some sample data that recreates the problem, and the invalid change() handler is also removed, we can take a look.

        Just a note that the fact that something worked in a previous version does not mean that there is a framework bug. Invalid usage (that is, code that depends on things that aren’t in the documentation) is still invalid usage, even if it happened to work anyway!

        But if this is a framework bug, and you can show that, then we will very much want to fix it!

        Comment

        Working...
        X