Question with datatable and making a quote from it

Question with datatable and making a quote from it

bobs64956bobs64956 Posts: 18Questions: 6Answers: 0
edited September 2020 in Free community support
<script>
$(document).ready(function(){

    fill_datatable();

    function fill_datatable(filter_supplier = '', filter_category = '')
    {
        var dataTable = $('#supplier_data').DataTable({

            serverSide: true,
            ajax:{
                url: "{{ route('projectprice.index') }}",
                data:{filter_supplier:filter_supplier, filter_category:filter_category}
            },
            columns: [
                {
                    data:'suitemID',
                    name:'suitemID'
                },
                {
                    data:'suName',
                    name:'suName'
                },
                {
                    data:'suitemBrand',
                    name:'suitemBrand'

                },
                {
                    data:'suitemCategory',
                    name:'suitemCategory'
                },
                {
                    data:'suitemDescription',
                    name:'suitemDescription'
                },
                {
                    data:'suID',
                    name:'suID'
                },
                {
                    data:'suitemCostExGST',
                    name:'suitemCostExGST'
                },
                {
                    "data": null,
                    "render": function(data) { return (data["suitemCostExGST"] * 1.1).toFixed(2)}
                },
                {

                    defaultContent: '<a href="{{ route('cart.add', $supplieritem->suitemID) }}">Add item</a>'
                },
            ]
        });
    }

When the user clicks on Add Item, I want it to be put into a quote in which the user can add more items or delete the item off the quote. Is there a way to do this or an example?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Are you using Editor?

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • bobs64956bobs64956 Posts: 18Questions: 6Answers: 0

    Hey Colin,

    http://live.datatables.net/tejonaxo/1/edit

    We are using an editor, currently the data is reading of a DB so it won't be displaying the data.

    I am just unsure on where to start in terms of creating a shopping cart. I kinda want it in a way where next to the data or record, there is a button called "add-item" in which it will capture the data of that and display it in a new table or area to be listed. Not sure if this is possible whiich is why I am unsure where to start as Datatables is new to me

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Your test case shows numerous console errors.

  • bobs64956bobs64956 Posts: 18Questions: 6Answers: 0

    That due to the database, not sure the best way to show it. But i've sent a screenshot of what it suppose to look like. It grabs the data from mySQL db and uses it to display the data. As seen in the screenshot, there is a new column which you can add item to cart.

    I'm not entirely sure like i've said above on how to code it in a way similar to a shopping cart

  • kthorngrenkthorngren Posts: 21,304Questions: 26Answers: 4,947
    Answer ✓

    This example shows how to add buttons to one of the cells and to retrieve the row data when clicking the button. You can do something similar with your Add Cart column to retrieve the row data.

    Kevin

This discussion has been closed.