KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

Input - Checkbox #1070

Closed Donald Orban opened this topic on on Aug 30, 2019 - 6 comments

Donald Orban commented on Aug 30, 2019

I have successfully got the Checkbox input to function, but when the post comes back the checkboxs aren't check with the values I have selected, they are all unchecked.

protected function defaultParamValues()
    {
        $case_subtype = CaseModel::select('case_subtype')->groupBy('case_subtype')->get();
        return array(
            "case_subtype" => $case_subtype->toArray()
        );
    }

    protected function bindParamsToInputs()
    {
        return array(
            "case_subtype" => 'case_subtype'
        );
    }

in the view blade..

CheckBoxList::create(array(
                        "name"=>"case_subtype",
                        "dataStore"=>$data->dataStore("data2"),
                        "dataBind"=>"case_subtype"
                    ));
KoolReport commented on Sep 2, 2019

I have not understood this line of code:

"dataStore"=>$data->dataStore("data2"),

it seems we do not have the $data variable that act like report. Do you set $data = $this; or sth.

Donald Orban commented on Sep 3, 2019

I am using laravel, so when I pass the value to the view, I name the report value $data. I've dug into the code and the part where the checkboxes are generated it searches for the value in the array, but the value is never set. Below is a var dump of the checkbox at the bottom of the init function.

CheckBoxList {#746 ▼
  #dataBind: array:2 [▼
    "value" => "case_subtype"
    "text" => "case_subtype_full"
  ]
  #display: "vertical"
  #defaultOption: null
  #name: "case_subtype"
  #data: array:4 [▼
    0 => array:2 [▼
      "text" => null
      "value" => null
    ]
    1 => array:2 [▼
      "text" => "Complaint"
      "value" => "COMP"
    ]
    2 => array:2 [▼
      "text" => "Incident Report"
      "value" => "IR"
    ]
    3 => array:2 [▼
      "text" => "Mortality"
      "value" => "MRC"
    ]
  ]
  #value: []
  #attributes: array:1 [▶]
  #clientEvents: []
  #params: array:4 [▶]
  #report: WidgetContainer {#750 ▶}
  #assetManager: null
  #language: null
  #languageMap: null
  #dataStore: DataStore {#662 ▶}
  #onReady: null
  #themeBase: null
  #themeCssClass: null
  #withoutLoader: false
}
Donald Orban commented on Sep 3, 2019

When the below line is executed, there is nothing in $this->value. $this->value is null.

<input type="checkbox" aName="<?php echo $this->name; ?>" name="<?php echo $this->name."[]"; ?>" value="<?php echo $value ?>" <?php echo(in_array($value,$this->value))?"checked":""; ?>>
KoolReport commented on Sep 6, 2019

The CheckBoxList should rendered inside the report view file otherwise it may not receive the binding value from report.

Donald Orban commented on Sep 11, 2019

The <input> above is rendered HTML inside the report view. It isn't rendering with $this->value. Below is the code in the view file. When I dump the values as the CheckBoxList class is called there is no value in $this->value; $this->name has the proper data in it. CheckBoxList::create(array(

      "name"=>"case_subtype",
      "dataStore"=>$data->dataStore("data2"),
      "dataBind"=>"case_subtype"

));

Donald Orban commented on Sep 11, 2019

Figured out a work around, I manually get the values from $_POST and assign the "value" parameter to the CheckBoxList like below, if anyone else is having issues.

                                CheckBoxList::create(array(
                                    "name"=>"checkBoxList",
                                    "dataStore"=>$data->dataStore("data2"),
                                    "dataBind"=>array(
                                        "value" =>"case_subtype",
                                        "text"=>"case_subtype_full"
                                    ),
                                    "value"=>$_POST['checkBoxList'],
                                    "attributes"=>array(
                                        "class"=>"form-control"
                                    )
                                ));

KoolReport Is Free and Open-Source!

KoolReport is a professional php reporting framework which saves you tons of time to construct dynamic data report & dashboard.

  • Connect to various datasources such as MySQL, SQL Server, MongoDB or even from CSV or Excel file.
  • Contain series of powerful built-in data processes for your data manipulation.
  • Generate stunning charts and graphs to help you communicate data insights to your audiences effectively.
  • Integrate seamlessly with any php frameworks such as Laravel, CodeIgniter, Symfony.
Download Now and register our tutorials to get started!

Download KoolReport
help needed

Inputs