KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Input, list of names with JSON extraction #2423

Closed Javier Gallardo opened this topic on on Nov 5, 2021 - 8 comments

Javier Gallardo commented on Nov 5, 2021
$arr = json_decode($response, true);
            $result = [];
            foreach($arr['projects'] as $project) {
            array_push($result, [
            "Nombre"=>$project["name"],
            "Id"=>$project["view_state"]["id"],
                ]);

            }
            echo $this->dataStore('Name')->count();

                    Select::create(array(
                    "name"=>"name",
                    "dataSource"=>$this->dataStore($result),
                    "dataBind"=>array(
                        "text"=>"Nombre",
                        "value"=>"Id",
                    ),
                        "attributes"=>array(
                            "class"=>"form-control"
                    )
                    ));
                    ?>
                </div>
            </div>
            <div class="form-group">
                <button class="btn btn-primary">Buscar</button>
            </div>
        </div>
    </form>
    <?php
        if($this->dataStore("Name")->countData()>0)
        {
    Table::create(array(
            "dataSource"=>$result
        ));

        }
Javier Gallardo commented on Nov 5, 2021

echo $this->dataStore('Nombre')->count();

count 0

Javier Gallardo commented on Nov 5, 2021

it only takes the names in the select but does not generate the table when pressing the button

I can generated a table when use

Table::create(array(

    "dataSource"=>$result
));
Sebastian Morales commented on Nov 8, 2021

If your $result variable is an array instead of a datastore object pls use "data" property like this:

Table::create(array(
    "data"=>$result, //$result is an array of data row (each data row should be an array of values)
));
daniel commented on Nov 15, 2021

it's the same, it's no use that

Sebastian Morales commented on Nov 16, 2021

var_dump($result); and let us know the result.

daniel commented on Nov 29, 2021

if($this->dataStore($result)->countData()>0) count 0

this is the only thing that doesn't work for me

daniel commented on Nov 29, 2021

daniel commented on Nov 29, 2021

array(10) { [0]=> array(2) { ["Nombre"]=> string(7) "Bes" ["id"]=> int(8) } [1]=> array(2) { ["Nombre"]=> string(16) "ClĂ­ni" ["id"]=> int(12) } [2]=> array(2) { ["Nombre"]=> string(4) "Demos" ["id"]=> int(7) } [3]=> array(2) { ["Nombre"]=> string(9) "Fala" ["id"]=> int(13) } [4]=> array(2) { ["Nombre"]=> string(3) "IE" ["id"]=> int(9) } [5]=> array(2) { ["Nombre"]=> string(5) "Raa" ["id"]=> int(11) } [6]=> array(2) { ["Nombre"]=> string(19) "Segur" ["id"]=> int(15) } [7]=> array(2) { ["Nombre"]=> string(6) "Tes" ["id"]=> int(1) } [8]=> array(2) { ["Nombre"]=> string(4) "UD" ["id"]=> int(10) } [9]=> array(2) { ["Nombre"]=> string(7) "Sodi" ["id"]=> int(14) } }

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None