Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Length is zero or Undefined for an Observable Variable

3200663Dec 10 2018 — edited Dec 11 2018

Hi,

My JET Version is 5.1.0

I have a table based on search and it is working fine .

I have a few lines of code used to construct the table based on a service.

My issue is i want to find out the length of an ko.observable(self.datasource) but it gives me zero or Undefined as highlighted below

$(document).ready(function () {

                  self.docSeqMethod();

                 });

                 

                self.ready=ko.observable(false); 

                self.datasource = ko.observable();

                self.docSeqMethod = function(){

                var deptArray=[];

                self.datasource(new oj.ArrayTableDataSource(deptArray,{ idAttribute: 'seq_id'}));

                self.pagingDatasourcedocseq =new oj.PagingTableDataSource(self.datasource());

                self.ready(false);

                   var aa = 'http://192.168.1.160:8080/apex/jetapps/admin/documentsequence');

                            console.log("aa data");

                    var loginCollection = new oj.Collection.extend({

                                 url: aa,

                                 model: new oj.Model.extend({

                                 idAttribute: 'seq_id',

                                 parse: parseMethoddocseq

                                }),

                         });            

                    new loginCollection().fetch({

                        success: function (response) {

                            console.log(response.toJSON());

                            res=response.toJSON();

                            console.log("response------"+res);

                            self.datasource(new oj.ArrayTableDataSource(res,{idAttribute: 'seq_id'}));

//Though my application works fine i just want to find the length of the datasource observable

                                    console.log("self.()length------"+self.datasource().length);// i am getting undefined here

                                    console.log("self length------"+self.datasource.length);//i am getting 0 here

                           self.pagingDatasourcedocseq = new oj.PagingTableDataSource(self.datasource());

                            console.log("ds"+self.datasource);

                            self.deptArray=res;

                             console.log("deptarray------"+deptArray);

                              self.ready(true);

                            },

                        error: function (jqXHR, textStatus, errorThrown) {

                            console.log('Error in fetch: ' + textStatus);

                            }

                        });

                    };

     

Thanks in Advance

Comments
Post Details
Added on Dec 10 2018
3 comments
403 views