Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
santlal0589
Contributor II
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);

} );

1 Solution

Accepted Solutions
pathiqvd
Creator III
Creator III

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,

View solution in original post

7 Replies
ErikWetterberg

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

santlal0589
Contributor II
Contributor II
Author

Thanks for reply Erik.

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

ErikWetterberg

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

santlal0589
Contributor II
Contributor II
Author

implemented above code , error coming qElemNumber not defined.

Erik can you provide sample Code  for LIST creation

pathiqvd
Creator III
Creator III

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
Contributor II
Contributor II
Author

showing error at

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

santlal0589
Contributor II
Contributor II
Author

You code  works in Qlik sense   Desktop

but in case of HUB getting below problem

After inspect getting following