Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

santlal0589
New Contributor II

List selection not working in Qliksense Mashup

Below code not working,

value of field is coming but selection is not happening in field Department.

Kindly help

Callback function:

function ListDep(reply, app){

console.info(reply);

$("#ListDep").empty();

var qObject=reply.qListObject;

$.each(qObject.qDataPages[0].qMatrix,function(){

var item=this[0];

var selt="";

if(item.qState == "S"){

currentReg=item.qText;

selt = " style=\"font-weight:bold;\"";

}

$("#ListDep").append('<li><a data-select="'+ item.qText+'"  href="#">'+ item.qText + '</a></li>');

});

$("#ListDep li").click(function(){

var value = $(this).text();

app.field('Department').selectMatch(value,false);

});

}

//open apps -- inserted here --

var app = qlik.openApp('Helpdesk Management.qvf', config);

//get objects -- inserted here --

app.getObject('QV01','hRZaKk');

//create cubes and lists -- inserted here --

app.createList({

"qFrequencyMode": "V",

"qDef": {

"qFieldDefs": [

"Department"

]

},

"qExpressions": [],

"qInitialDataFetch": [

{

"qHeight": 20,

"qWidth": 1

}

],

"qLibraryId": "RBBKJP"

}, ListDep);

} );

Tags (2)
1 Solution

Accepted Solutions
pathiqvd
Contributor III

Re: List selection not working in Qliksense Mashup

Hi,

Try this one,

In js:-

app.createList({

"qFrequencyMode": "V",

"qDef": {

"qFieldDefs": [

"YEAR"

]

},

"qExpressions": [],

"qInitialDataFetch": [

{

"qHeight": 20,

"qWidth": 1

}

],

"qLibraryId": null

},showData);

$(document).on( "click", "[data-select]", function() {

var value = $(this).data('select');

app.field('YEAR').selectValues([value], false, false);

$('#QV011 .dropdown button').html(value + ' <span class="caret"></span>');

});

function showData(reply, app){

$('#QV011 .dropdown ul').empty()

$.each(reply.qListObject.qDataPages[0].qMatrix, function(key, value) {

if (typeof value[0].qText !== 'undefined') {

$('#QV011 .dropdown ul').append('<li><a data-select="'+ value[0].qText+'" href="#">'+ value[0].qText+'</a></li>');

}

});

}

In Html:-


<div class="col-xs-12 col-sm-12 col-md-2 " id="QV011" style="height:55px;">

<div class="dropdown" style="padding-top: 10px;">

<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">

Year

<span class="caret"></span>

</button>


<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">

</ul>

</div>

</div>

Thanks & Regards,

7 Replies
erik_wetterberg
Valued Contributor III

Re: List selection not working in Qliksense Mashup

Hi,

It might be because you take the text of the li element, which might include whitespace ( check jQuery documentation).

Perhaps you should use the data-select attribute?? Even better is to use the selectValues method. In that case you should save qElemNumber in an attribute instead.

Hope this helps

Erik Wetterberg

Erik Wetterberg
https://extendingqlik.upper88.com/
santlal0589
New Contributor II

Re: List selection not working in Qliksense Mashup

Thanks for reply Erik.

Kindly elaborate the 2nd part of solution "you should save qElemNumber in an attribute instead."

erik_wetterberg
Valued Contributor III

Re: List selection not working in Qliksense Mashup

Hi,

Something like this(not actually tested):

qListObject.qDataPages[0].qMatrix.forEach( function ( row ) {

  html += '<li data-value="' + row[0].qElemNumber + '">' + row[0].qText + '</li>';

});

$("#ListDep li").click( function () {

if ( this.hasAttribute( "data-value" ) ) {

  var value = parseInt( this.getAttribute( "data-value" ), 10 );

  app.field('Department').selectValues( [value], false );

}}

);

Hope this helps

Erik Wetterberg

Erik Wetterberg
https://extendingqlik.upper88.com/
santlal0589
New Contributor II

Re: List selection not working in Qliksense Mashup

implemented above code , error coming qElemNumber not defined.

Erik can you provide sample Code  for LIST creation

pathiqvd
Contributor III

Re: List selection not working in Qliksense Mashup

Hi,

Try this one,

In js:-

app.createList({

"qFrequencyMode": "V",

"qDef": {

"qFieldDefs": [

"YEAR"

]

},

"qExpressions": [],

"qInitialDataFetch": [

{

"qHeight": 20,

"qWidth": 1

}

],

"qLibraryId": null

},showData);

$(document).on( "click", "[data-select]", function() {

var value = $(this).data('select');

app.field('YEAR').selectValues([value], false, false);

$('#QV011 .dropdown button').html(value + ' <span class="caret"></span>');

});

function showData(reply, app){

$('#QV011 .dropdown ul').empty()

$.each(reply.qListObject.qDataPages[0].qMatrix, function(key, value) {

if (typeof value[0].qText !== 'undefined') {

$('#QV011 .dropdown ul').append('<li><a data-select="'+ value[0].qText+'" href="#">'+ value[0].qText+'</a></li>');

}

});

}

In Html:-


<div class="col-xs-12 col-sm-12 col-md-2 " id="QV011" style="height:55px;">

<div class="dropdown" style="padding-top: 10px;">

<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">

Year

<span class="caret"></span>

</button>


<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">

</ul>

</div>

</div>

Thanks & Regards,

santlal0589
New Contributor II

Re: List selection not working in Qliksense Mashup

showing error at

$.each(reply.qListObject.qDataPages[0].qMatrix, function(key, value)

santlal0589
New Contributor II

Re: List selection not working in Qliksense Mashup

You code  works in Qlik sense   Desktop

but in case of HUB getting below problem

After inspect getting following