Announcement

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

    DecimalPrecision in ListGridField for field type localeFloat

    Hi,
    I'm using SmartClient version 10.0. on Google Chrome. JavaScript errors are not present.
    My ListGrid config looks like:

    isc.NumberUtil.addClassProperties({ groupingFormat: 1, groupingSymbol: ".", decimalSymbol: ",", decimalPrecision: 4 });

    isc.ListGrid.create({
    ID: "warehouseOperationItemsGrid",
    /* Customize look */
    canResizeFields: true,
    alternateRecordStyles: true,
    wrapHeaderTitles: true,
    autoFitHeaderHeights: true,
    hilites: hiliteArray,
    autoFitFieldWidths: false,
    wrapCells: true,
    fixedRecordHeights: false,

    /* Data manipulation */
    showAllRecords: true,
    autoFetchData: false,
    autoSaveEdits: false,
    canEdit: false,
    editEvent: "doubleClick",
    listEndEditAction: "next",
    enterKeyEditAction: "nextRow",
    escapeKeyEditAction: "done",
    validateOnChange: true,
    modalEditing: true,
    selectionType: "single",

    fields: [
    ..................
    {
    name: "quantity",
    title: "Utrošak",
    align: "right",
    width: "10%",
    //type: "float", --comment
    type: "localeFloat",

    //format: "#,##0.0000", --comment
    //format: "#,0000.0000", --comment
    //format: "#,####0.0000", --comment
    //format: "0.0000", --comment
    decimalPrecision: 4

    },
    ..................

    ]
    })

    The problem is that I have to use localeFloat type because of comma separator. Float type uses dot sperator and this not suit my needs. Also all rows for this decimal field have to had 4 decimal places, including zeros. When the grid is populated with data (warehouseOperationItemsGrid.setData()) decimal format is OK, all rows have 4 decimal places. But the problem is when I start editing list grid row. Last 2 decimal places are cut off. For example if in the row is value: 1,2345 and I start editing row, edit value is 1,23 (4 and 5 are not present). Why is this happening? Documentation says that property decimalPrecision is only used with type float, but with float I can't use comma decimal separator. Any suggestions?

    #2
    decimalPrecision also applies to type localeFloat, which is a sub-type of float.

    It's not clear what your issue is here. First, test with the latest patched version (see smartclient.com/builds). If there is still an issue, please try explaining again specifically what the problem is.

    Comment


      #3
      Please look at the gif in attachment. I also tried the same code on SmartClient 11.1 version and problem still persists. Is it problem that grid doesn't use data source? When I use type float for field and enter in edit mode for row all four decimal places are there, but when using localeFloat you can see what happen. I don't now what I'm doing wrong. :/
      Attached Files

      Comment


        #4
        We previously asked you to update to the latest patched version and retest - if you’ve actually done so, please report the version tested (including date of build).

        We also currently don’t have complete information necessary to reproduce the issue, because you haven’t provided sample data and your code would crash if run standalone.

        Comment


          #5
          Here is demo code which won't crash:

          //-------------------------------------------------------------
          isc.NumberUtil.addClassProperties({ groupingFormat: 1, groupingSymbol: ".", decimalSymbol: "," });

          isc.ListGrid.create({
          ID: "warehouseOperationItemsGrid",
          /* Customize look */
          canResizeFields: true,
          alternateRecordStyles: true,
          wrapHeaderTitles: true,
          autoFitHeaderHeights: true,
          autoFitFieldWidths: false,
          wrapCells: true,
          fixedRecordHeights: false,
          width: 200,
          height: 200,

          /* Data manipulation */
          showAllRecords: true,
          autoFetchData: false,
          autoSaveEdits: false,
          canEdit: true,
          editEvent: "doubleClick",
          escapeKeyEditAction: "done",
          listEndEditAction: "next",
          enterKeyEditAction: "nextRow",
          validateOnChange: true,
          modalEditing: true,
          selectionType: "single",

          fields: [
          {
          name: "quantity",
          title: "Utrošak",
          align: "right",
          type: "localeFloat",
          //type: "float",
          decimalPrecision: 4
          },
          ]
          });


          var gridData=[
          {
          "quantity": 1.2345
          },
          {
          "quantity": 2.7658
          },
          {
          "quantity": 3.9874
          },
          {
          "quantity": 4.6425
          },
          {
          "quantity": 5.7846
          },
          ];

          warehouseOperationItemsGrid.setData(gridData);
          //-------------------------------------------------------------

          I tried this code on yours Feature Explorer (on the web) for versions: 10.0 and 11.1. Like I said problem is when you enter in edit mode (double click on row) last two decimal places are cutted of for type localeFloat, on type float everything works fine.

          Can you please tell me on which version of SmartClient this won't happen? Or can you direct me what to do with this sample code so that decimal places won't be cutted of when you enter in edit mode.

          Comment


            #6
            The problem here is that framework code is not propagating your precision setting from the Field to it's editor - that's been fixed for builds dated June 30 and later.

            In the meantime, you can fix the problem in your test by adding editorProperties: { decimalPrecision: 4 } to your field-spec, applying the value to the editor as well as the field.

            Comment


              #7
              Thanks, adding this property everything works fine.

              Comment

              Working...
              X