lundi 11 mars 2019

Laravel Table Structure Does Not Appear

I am new to laravel, trying to create a form in a table which allows the user to select the item and enter the quantity.The item option will be taken from the database. Aside that, user is able to click on "New Row" and the table will automatically generate a new row and "Remove" button to remove the row. The table structure is not coming out. Please help me with this, I've definitely no idea what's wrong with it.

My Controller

    $deliveryitems = DB::table('stocks')
    ->select('inventories.Item_Code')
    ->leftJoin('inventories','stocks.inventory_Id','=','inventories.Id')
    ->get();


    $quantity = DB::table('stocks')
    ->select('stocks.Quantity')
    ->get();

The editor

itemeditor = new $.fn.dataTable.Editor( {
           ajax: "",
           table: "#itemlisttable",
           idSrc: "stocks.inventory_Id",
           fields: [
                  {
                   label: "Item:",
                   name: "inventories.Item_Code",
                   type:  'select'
                   options: [
                   { label :"", value: "" },
                   @foreach($deliveryitems as $item)
                   { label :"", value: "" },
                   @endforeach
                            ],
                  },{
                     label: "Quantity:",
                     name: "stocks.Quantity",
                     type:   'textarea',
                 }
                ]} );

The table function

$('#itemlisttable').on( 'click', 'tr', function () {
itemid = itemlisttable.row( this ).data().stocks.inventory_Id;
});

The DataTable

itemlisttable=$('#itemlisttable').DataTable( {
                       ajax: {
                         "url": "",
                         "data": {
                             "UserId": 
                         }
                       },
                           columnDefs: [{ "visible": false, "targets": [1] },{"className": "dt-center", "targets": "_all"}],
                        responsive: false,
                        dom: "Blftp",
                        iDisplayLength:100,
                        bAutoWidth: true,
                        iDisplayLength:10,
                        rowId:"stocks.inventory_Id",
                        order: [[ 5, "asc" ]],
                        columns: [
                        { data: "stocks.inventory_Id", title: "Items"},
                        { data: "stocks.Quantity", title: "Quantity"}

                ],
                             select: {
                                     style:    'os',
                                     selector: 'tr'
                                   },
                             buttons: [
                                      { text: 'New Row',
                                      action: function ( e, dt, node, config ) {
                                          editor
                                             .create( false )
                                             .submit();
                                      },
                                    },
                                    { extend: "remove", editor: editor }

                             ],

                 });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire