Dear KoolReport team,
I am trying to bind data to the select box. But it displays empty. Here is my code. Please let me know where I done mistake.
SelectList.php(Controller)
class SelectList extends CI_Controller
{
public function index()
{
$this->load->helper('url');
$this->load->database('MainiDM');
include APPPATH."reports\SelectList_Ex.php";
$report = new SelectList_Ex;
$report->run()->render();
}
}
SelectList_Ex.php(reports)
class SelectList_Ex extends \koolreport\KoolReport
{
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
function defaultParamValues()
{
return array(
"Customer"=>null,
);
}
function bindParamsToInputs()
{
return array(
"Customer"
);
}
public function settings()
{
return array(
"dataSources"=>array(
"select"=>array(
"connectionString"=>" ------"
)
)
);
}
public function setup()
{
$this->src('select')
->query("SELECT DISTINCT CustomerName from EnquiryDataView ORDER BY CustomerName")
->pipe($this->dataStore("customers"));
}
SelectList_Ex.view.php
<?php
use \koolreport\inputs\Select;
$CustomerName = "";
$this->dataStore("customers")->popStart();
while($row=$this->dataStore("customers")->pop())
{
$CustomerName = $row["CustomerName"];
echo $CustomerName;
}
?>
<form method="post">
<?php
Select::create(array(
"name" => "Customer",
"datastore"=>$this->dataStore('customers'),
"dataBind"=>array(
"text"=>"CustomerName",
"value"=>"CustomerName"),
"attributes"=>array(
"class"=>"form-control"),
));
?>
<div class="form-group">
<button class="btn btn-primary">Submit</button>
</div>
</form>
By printing customername with echo statement, I got the data as above, but I want to bind this data to SelectBox.
Please Please give me the solution as early as possible.