Hi
I try to use QlikSense Field API like this: select method ‒ Qlik Sense
This is my code:
And this is the result in Development Console:
The Problem is I can't get acces to the rows Array.
It is undefined, in row 251.
If I print "console.log( fields.rows)" I get this:
How can I get acces to the Array?
The length is 0, seem like an error to me
Hello,
You are most probably trying to access the data before it is available to you. The developer console provides this data when it is available giving you the possibility to drill down and investigate each row which can seem confusing sometimes. In the code you need to bind the field to a listener and work with the data when it has arrived. E.g.
var data = qlikApp.field("the-field").getData();
console.log(data); // Will show the data in develop console with rows its length etc
console.log(data.rows.length); // will most probably show 0 since the data hasn't arrived yet
data.OnData.bind(
function(){
var len = data.rows.length;
console.log(len); // will show the real size of rows since the data is available
for (var i = 0; i < len; i++){
console.log(data.rows.qText + data.rows.qState); // State flag (is the data selected or not)
}
});
Hope it helps.
Hello,
You are most probably trying to access the data before it is available to you. The developer console provides this data when it is available giving you the possibility to drill down and investigate each row which can seem confusing sometimes. In the code you need to bind the field to a listener and work with the data when it has arrived. E.g.
var data = qlikApp.field("the-field").getData();
console.log(data); // Will show the data in develop console with rows its length etc
console.log(data.rows.length); // will most probably show 0 since the data hasn't arrived yet
data.OnData.bind(
function(){
var len = data.rows.length;
console.log(len); // will show the real size of rows since the data is available
for (var i = 0; i < len; i++){
console.log(data.rows.qText + data.rows.qState); // State flag (is the data selected or not)
}
});
Hope it helps.
Hi,
I am using this api in mashup.
Sometimes rows length is coming 0 even after binding and sometimes (with actual length ) it works.
Any solution for this?
Satya