Forum Stats

  • 3,837,252 Users
  • 2,262,243 Discussions
  • 7,900,238 Comments

Discussions

oj-table not rendering on UI

Manikanta_Rendla
Manikanta_Rendla Member Posts: 9 Green Ribbon

Hi all,

I am unable to display oj-table on UI in oracle JET. Please refer my code.

customer.html:

<!--

 Copyright (c) 2014, 2022, Oracle and/or its affiliates.

 Licensed under The Universal Permissive License (UPL), Version 1.0

 as shown at https://oss.oracle.com/licenses/upl/

 -->

<div class="oj-hybrid-padding">


  <oj-table id="table" aria-label="Employee Table" data="[[datasource]]" columns='[{"headerText": "Employee Number", "field": "empno"},

                      {"headerText": "Employee Name","field": "ename"},

                      {"headerText": "Job","field": "job"},

                      {"headerText": "Manager","field": "mgr"},

                      {"headerText": "Hire Date","field": "hiredate"},

                      {"headerText": "Salary","field": "sal"},

                      {"headerText": "Commission","field": "comm"},

                      {"headerText": "Dept No","field": "deptno"}]' class="demo-table-container">

  </oj-table>

</div>


customer.js:


/**

 * @license

 * Copyright (c) 2014, 2022, Oracle and/or its affiliates.

 * Licensed under The Universal Permissive License (UPL), Version 1.0

 * as shown at https://oss.oracle.com/licenses/upl/

 * @ignore

 */

/*

 * Your customer ViewModel code goes here

 */

define(['ojs/ojcore','jquery', 'knockout','ojs/ojtable','ojs/ojarraytabledatasource'],

 function(oj,$, ko) {

    function CustomerViewModel() {


    var employeeArray=[{empno:1001,ename:'Test',job:'test job',mgr:123,hiredate:'12-JAN-2003',sal:100,comm:123,deptno:10}];

   

        this.datasource= new ArrayTableDataSource(

            employeeArray,

            {idAttribute:'empno'}

        );


    }


   


    /*

     * Returns an instance of the ViewModel providing one instance of the ViewModel. If needed,

     * return a constructor for the ViewModel so that the ViewModel is constructed

     * each time the view is displayed.

     */

    return CustomerViewModel;

  }

);


Here I am trying to display static array table data on UI. Output is not getting on UI.

Could any one help me with this.

Thanks in advance

Manikanta.R

Tagged:

Answers

  • You don't say which version of JET you are using, but it appears that you have not provided an argument for the ArrayDataProvider in the callback function of your define block.

    This

    define(['ojs/ojcore','jquery', 'knockout','ojs/ojtable','ojs/ojarraytabledatasource'],
     function(oj,$, ko) {
      function CustomerViewModel() {  ....  }
    

    Should be

    define(['ojs/ojcore','jquery', 'knockout','ojs/ojarraydataprovider','ojs/ojtable'],
     function(oj,$, ko, ArrayDataProvider) {
      function CustomerViewModel() {  ...  }
    

    Notice that I have changed the order of the array elements in the first argument of the define block. The order of the array elements must match the order of the callback function arguments. I have also changed you library reference from "ojarraytabledatasource" to "ojarraydataprovider". The DataSource based libraries have been deprecated for over 3 years now and should no longer be used.