Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81923

Putting together different data from different tables

$
0
0

That the situation:
I have three different table, i must arrange an array with data from this table...

Here a part of Json to better explain

"data": [
    {
      "DT_RowId": "row_150",
      "ol": {
        "id": "150",
        "ol": "0",
        "fase": "8",
        "centrale": "roma",
        "Data_Inizio": "2017-11-17",
        "Data_Fine": "2017-11-17",
        "cliente_id": "3",
        "fatturato": "1",
        "Materiali_id": "",
        "costi_materiali": null,
        "impiegati_id": null,
        "Time_Stamp": "2017-12-06 10:49:51"
      },
      "clienti": {
        "nome": "FastWeb"
      },
      "materiali": [
        {
          "id": "7",
          "codice": "F-LCLC01-DX-B"
        }
      ],
      "movimenti": [
        {
          "id": "355",
          "quantita": "1",
          "materiale_id": "7"
        }

The last part: I have an array in "movimenti" and another in materiali, i "movimenti" i need to use "codice" and not "materiale_id.

Here the queries:

->join(
        Mjoin::inst( 'materiali' )
            ->link( 'ol.id', 'vardisp.olid' )
            ->link( 'materiali.id', 'vardisp.matid' )
            ->fields(
                Field::inst( 'id' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'materiali' )
                        ->value( 'id' )
                        ->label( 'codice' )
                    ),

                Field::inst( 'codice' )

            )
    )





   ->join(
        Mjoin::inst( 'movimenti' )

            ->link( 'movimenti.ad_ol_id', 'ol.id' )

            ->fields(
                Field::inst( 'id' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'movimenti' )
                        ->value( 'id' )
                        ->label( array ('quantita', 'materiale_id' ))

                    ),

                Field::inst( 'quantita' ),
                Field::inst( 'materiale_id' )


            )
    )

and here how I use the data on JS


{data: "movimenti", render: function ( data, type, full ) { return $.map( data, function ( d, i ) { return d.materiale_id +' '+ d.quantita; } ).join( ', ' ); }}

any ideas?
tx a lot


Viewing all articles
Browse latest Browse all 81923

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>