Author Topic: Create a filter that is a <select>  (Read 175 times)

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 160
    • View Profile
Create a filter that is a <select>
« on: August 04, 2025, 08:24:14 pm »
I want to use a select as a filter and not the standard pqGrid selector.  The following works, but seems messy:

Code: [Select]
rating_filter = {
crules:[{condition:"contain"}],
// type:"select", // HAS NO EFFECT
init: function(ui)
{
// Cretae a new <select>
var sel = $("<select>", {style:"width:100%; text-align:"+dir})
.insertAfter(ui.$editor)
.change(function(){ ui.$editor.val(this.value).change(); });
// Hide the input
ui.$editor.hide();
// Add the options
$("<option>", {html:"All", value:""}).appendTo(sel);
for(let i=0; i<6; i++)
$("<option>", {text:"★".repeat(i), value:i}).appendTo(sel);
ui.listener = "change";
// Hide the clear icon
ui.$cell.find("span.pq-clear-icon").hide();
// Send back message all good
return true;
}
};

Is there a better way?
« Last Edit: August 04, 2025, 08:27:59 pm by jplevene »