KoolReport's Forum

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

Input, list of names with JSON extraction #2466

Closed Javier Gallardo opened this topic on on Nov 29, 2021 - 20 comments

Javier Gallardo commented on Nov 29, 2021

Is it necessary to use dataStore or dataSources to be able to process the information?

$arr = json_decode($response, true);

        $result = [];
        foreach($arr['projects'] as $project) {
        array_push($result, [
        "Nombre"=>$project["name"],
        "Id"=>$project["view_state"]["id"],
            ]);
        }
                Select::create(array(
                "name"=>"name",
                "dataSource"=>$this->dataStore($result),
                "dataBind"=>array(
                    "text"=>"Nombre",
                    "value"=>"Id",
                ),
                    "attributes"=>array(
                        "class"=>"form-control"
                )
                ));
                Table::create(array(
                    "dataSource"=>$result
                    ));
                ?>
            </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
    ));

} //var_dump($result) = 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) } }

Javier Gallardo commented on Nov 29, 2021

Javier Gallardo commented on Nov 29, 2021

.

Javier Gallardo commented on Nov 29, 2021

Sebastian Morales commented on Nov 30, 2021

Where is your $this->dataStore("Name") that appears in

if($this->dataStore("Name")->countData()>0) ...

?

It's not necessary to use DataStore. If you don't have a datastore, an array like $result could be used directly

    Table::create(array(
        "data"=>$result,
        ...
    ));
Javier Gallardo commented on Dec 2, 2021

how could I create a dataStore??? Maybe I need dataStore for IF to process table with input

I need input to display the table when selecting a data from $ result

Sebastian Morales commented on Dec 3, 2021

Ways to create a datastore:

1 . Using data pipe in a report's setup:

// MyReport.php
...
$this->src(...)
...
->pipe($this->dataStore(...));

2 . Using an array anywhere:

// MyReport.php or MyReport.view.php
$data = getData();
$meta = getMeta(); //this could be an empty array
$this->myDataStore = new \KoolReport\core\DataStore($data, $meta);
Javier Gallardo commented on Dec 6, 2021

1 // MyReport.php ... $this->src(...) ... ->pipe($this->dataStore(...));

Can you help me with a more detailed example, please? I don't know what to put in the ellipsis

2 ... 3 how could IF to process table with input

I need input to display the table when selecting a data from $ result

Sebastian Morales commented on Dec 7, 2021

Did you jump into this without ever reading quick start, documentation, or demo? I think you had better start from the beginning:

https://www.koolreport.com/docs/quick_start/

https://www.koolreport.com/examples/reports/datasources/array_report/

For the 2nd link, the example code (MyReport.php, MyReport.view.php) could be viewed at the end of the page.

Javier Gallardo commented on Dec 7, 2021

I already read all the documentation ...

Sebastian Morales commented on Dec 8, 2021

If you read quick start, documentation and understood them pls try to write code or copy and modify our example code for your data. If you didn't understand any specific part let us know exactly which it is. You provide general information we can only response with general guides. You provide detail information we can response with detail guides.

Javier Gallardo commented on Dec 8, 2021

I need input to display the table when selecting a data from $ result

Javier Gallardo commented on Dec 11, 2021

do you have any idea how????

Javier Gallardo commented on Dec 11, 2021

I need input to display the table when selecting a data from $ result

Javier Gallardo commented on Dec 11, 2021

do you have any idea how????

Sebastian Morales commented on Dec 13, 2021

Pls try this code in your report view:

//MyReport.view.php
print_r($result); echo "<br>";
Table::create(array(
    "data" => $result
));

If there's any error pls post your screenshots so that we know what it is. Tks,

Javier Gallardo commented on Dec 14, 2021

that does not have any difference with what I already published ...

Javier Gallardo commented on Dec 14, 2021

I need input to display the table when selecting a data from $ result

Javier Gallardo commented on Dec 14, 2021

I need something like that https://www.koolreport.com/examples/reports/advanced/input_and_export/

but are dont know how I cant, because the examples are in sql

you could give me with example for me $result

Javier Gallardo commented on Dec 14, 2021

also the published examples there is nothing written about what each code does

Javier Gallardo commented on Dec 14, 2021

I've been trying to work with you for 3 months and I haven't made any progress

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