I was able to create a messy one on my own. it makes something like in the picture, but was wondering if in the future this is something that would be just default in KoolReports. I made the these changes to the code to get it to work as well:
My View code:
BSelect::create(array(
'name'=>"my_select",
"multiple"=>true,
"placeholder"=>"Select customer",
"data"=>array(
"permit #"=>"permitnum_id",
"permit Date"=>"permit_dt",
"text 1"=>"text1",
"fee" => "feename",
"payment" => "payment",
),
"optgroup" =>["permit" => ["permit #",
"permit Date",
"text 1"],"Fees"=>["fee",
"payment",]],
"options"=>array(
'enableClickableOptGroups'=> true,
'enableCollapsibleOptGroups' => true,
'enableFiltering' => true,
'includeSelectAllOption' => true,
),
));
BSelect.php
protected $optgroup;
protected function onInit()
{
parent::onInit();
$this->multiple = Utility::get($this->params,"multiple",false);
$this->optgroup = Utility::get($this->params,"optgroup",null);
//continue with Bselect.php
}
Bselect.tpl.php
if($this->optgroup){
foreach($this->optgroup as $key=>$group){
echo('<optgroup label="'.$key.'"');
foreach($group as $row){
foreach($this->data as $item)
{
$value = $item["value"];
$text = $item["text"];
if($text == $row){
?>
<option value="<?php echo $value; ?>" <?php echo (($this->multiple)?in_array($value,$this->value):($value==$this->value))?"selected":""; ?>><?php echo $text; ?></option>
<?php
}
}
}
echo('</optgroup>');
}
}else{
foreach($this->data as $item)
{
$value = $item["value"];
$text = $item["text"];
?>
<option value="<?php echo $value; ?>" <?php echo (($this->multiple)?in_array($value,$this->value):($value==$this->value))?"selected":""; ?>><?php echo $text; ?></option>
<?php
}
}
Anyways, thanks for the time, and i hope to hear back from you soon.