ParamQuery grid support forum
General Category => Help for ParamQuery Select => Topic started by: rsgmedia on July 03, 2017, 10:59:13 am
-
We are using pqSelect (multiselect using checkbox) in paramquery grid.
What we need is checkbox change event of pqSelect here. Is there any option to achieve this?
-
There is change event whenever checkbox is selected / unselected.
https://paramquery.com/select (2nd example of multiple select )
-
Thanks. event is firing and I am able to get all selected options using this but when change event is fired on check/uncheck of any option I am not able to get that option. (given that options of this list are not having unique values).
-
Ok, so you mean to get individual checked / unchecked options rather than complete list of selected options in every change event.
That can be done by calculating difference between old and new set of selected options. Please open your browser's console to see the output.
//initialize the pqSelect widget.
$("#select1").pqSelect({
multiplePlaceholder: 'Select Countries',
checkbox: true //adds checkbox to options
}).on("change", function(){
//save initial value.
var oldVal = $("#select1").val() || [];
return function( evt ){
var newVal = $(this).val() || [],
diff, state;
//console.log(oldVal);
//console.log(newVal);
if(oldVal.length > newVal.length){
state = "unchecked";
diff = $(oldVal).not(newVal).get();
}
else{
state = "checked";
diff = $(newVal).not(oldVal).get();
}
console.log("diff: ", diff, " state: ", state);
oldVal = newVal;
}
}()).pqSelect( 'open' );
http://jsfiddle.net/dLvx6u63/66/
-
Thanks!! :)