5 Replies Latest reply on Apr 10, 2018 3:15 PM by jmarc

    how to get type column in IG ?

    jmarc

      hello,

      i would find a way to get from javascript the column type (Number Field,Date picker ..) for an Interactive Grid.

       

      so, if i have the type column like NumberField, i could do a conversion like

      parseFloat(model.getValue(record, "TESTCOL1"));

       

      the goal is to make some generic calculation.

       

      regards

      jm

       

      apex 5 1.4

        • 1. Re: how to get type column in IG ?
          Dharmendra Kumar-Oracle

          Yes you can do the conversion, but only thing you should take care if the number column has format in it. You will have to replace all the commas (,) from it before conversion.

          However, I would like to know how you are identifying the column type.

           

          Regards,

          Dharmnedra

          • 2. Re: how to get type column in IG ?
            jmarc

            that's my question : how to get the column type from JS ?

             

            regards

            jm

            • 3. Re: how to get type column in IG ?
              jmarc

              for the moment, i use a preprocess in the page to give the informations in javascript array

               

              declare

              v_cursor_2  SYS_REFCURSOR;

              name_col varchar2(200);

              data_type_col varchar2(200);

              region_id_static_IG varchar2(200);

              begin

               

              region_id_static_IG :='emp';

               

              htp.p('<script type="text/javascript">');

              htp.p('var type_colonne={};');

                htp.p('type_colonne["'|| region_id_static_IG ||'"] = {};');

              OPEN v_cursor_2 FOR  'select  name,data_type  from apex_appl_page_ig_columns where data_type is not null and application_id =NV(''APP_ID'') and page_id=NV(''APP_PAGE_ID'') and REGION_ID =(select REGION_ID from APEX_APPLICATION_PAGE_REGIONS where STATIC_ID = '''|| region_id_static_IG || ''' and  application_id =NV(''APP_ID'') and page_id=NV(''APP_PAGE_ID'')  )';

                LOOP

                  FETCH v_cursor_2 INTO name_col,data_type_col  ;

                  EXIT WHEN v_cursor_2%NOTFOUND;

               

                  htp.p('type_colonne["' || region_id_static_IG || '"]["'|| name_col || '"]="' || data_type_col || '";');

                   

                END LOOP;

               

                CLOSE v_cursor_2;

               

               

                htp.p('</script>');

               

              end;

              • 4. Re: how to get type column in IG ?
                John Snyders-Oracle

                Hi jm,

                You can get the data type from the client. It is not stored in the model or grid widget they don't care about server data types. But the Interactive Grid does have that info.

                Try this in console, changing emp to the static id of your IG.

                 

                apex.region("emp").widget().interactiveGrid("option","config").columns.forEach(function(c) {console.log("Column " + c.name + " has type " + c.dataType); });

                 

                Keep in mind that JavaScript and Oracle Database do math slightly differently due to difference in number representation.
                Also if you write a number back to the model (with model.setValue) turn it back into a string or you may have trouble saving the changes.

                 

                Regards,
                -John

                • 5. Re: how to get type column in IG ?
                  jmarc

                  thanks a lot john

                   

                  best regards

                  jm