4 Replies Latest reply on Nov 17, 2017 10:12 AM by Matt Mulvaney

    Interactive Grid API set Number Column Format Mask

    Matt Mulvaney

      Hi

       

      My question is: How do you set the Format Mask of a Interactive Grid NUMBER column using the Interactive Grid API?

       

      I know I can easily set this declarative on the column to something like 999G999G999G999G990D00, but I want to do this using the IG API.

       

      I've tried setting columns[].appearance.formatExample and columns[].appearance.formatMask but either these are the wrong settings or they are ignored.

       

      Have anyone done this and can provide an example?

       

      Thanks

      Matt

        • 1. Re: Interactive Grid API set Number Column Format Mask
          John Snyders-Oracle

          Hi Matt,

          The column config appearance formatMask and formatExample are currently used in very few places in interactive grid. The chart view does something with them and the formatExample is used in the filter dialog as a placeholder but only for dates. IG may expand how these values are used in the future.

           

          The server is responsible for formatting the data according to the declarative format mask. So even if you changed the formatMask on the client side it wouldn't affect how the sever turns numbers (or dates) into strings.

           

          What is it you are trying to achieve?

           

          Regards,
          -John

          • 2. Re: Interactive Grid API set Number Column Format Mask
            Matt Mulvaney

            Thanks John

             

            My IG Query is based on a XML web service; I'm using XMLTABLE in SQL essentially to bring in my data.

             

            My 20 columns are all fetched as VARCHAR2; but they can be a mix of datatypes, e.g first 18 Numbers followed by 1 Date and 1 String; or 10 Strings followed by 10 Dates - basically any combination.

             

            Using metadata contained in that XML, i'm using the advanced JS Config to say "hey col1, you are now a NUMBER, you have this label, this css class, right column alignment and hopefully this format mask".

             

            This is all working brilliantly; filters work, date ranges can be filtered, etc,etc.

             

            The numbers cannot be formatted at source, so I'm supplied a number like 1000.5 which I need to tell the IG to format as 1,000.50

             

            Thanks again

            Matt

            • 3. Re: Interactive Grid API set Number Column Format Mask
              John Snyders-Oracle

              HI Matt,

              Is this IG used for editing or just reporting?

               

              It seems to me that from the servers perspective all the columns are text so they will always be sorted and filtered that way. Depending on how the dates and number are formatted somethings may be unexpected like "9" > "10". The server needs fixed types for the columns. In your case I think you will need to do the formatting on the client side.

               

              Client side formatting is something I have been thinking about because currently if you edit a number column that is formatted it is displayed as entered and not formatted again until the IG is saved. Can't say if or when this will be built into IG.

               

              You could do this by looping over the model and updating the number string with the desired format. The IG Cookbok page Dynamic Column Total shows how to loop over the model whenever it is updated.

               

              You could do this not in the model but as the value is rendered to the DOM by implementing your own apex.item.displayValueFor function. There is an example of this in the IG Cookbook page Report Checkbox Column. I think this would be the simplest way.

               

              We don't currently have a built in function to do number formatting. You may find apex.locale.getDecimalSeparator and apex.locale.getGroupSeparator useful in your number formatting code.

               

              Regards,

              -John

              • 4. Re: Interactive Grid API set Number Column Format Mask
                Matt Mulvaney

                Thanks for the reply John; I am encountering the "9" > "10" issue you described

                 

                Also related: See my comment

                "Using metadata contained in that XML, i'm using the advanced JS Config to say "hey col1, you are now a NUMBER, you have this label, this css class, right column alignment and hopefully this format mask"

                 

                It appears that setting a label and heading via the JS Advanced Configuration section does work for all IG label/heading functions except for the download functionality. If the IG is downloaded to CSV or HTML (these are the only ones I tested) the column heading reverts to the label held in page designer - rather than the one set in the IG configuration. It would be nice to see this use the labels I set in the config instead.

                 

                Regards

                Matt