Question with datatable and making a quote from it

Question with datatable and making a quote from it

bobs64956bobs64956 Posts: 15Questions: 5Answers: 0
edited September 16 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: 9,558Questions: 0Answers: 1,582

    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: 15Questions: 5Answers: 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: 2,730Questions: 22Answers: 311

    Your test case shows numerous console errors.

  • bobs64956bobs64956 Posts: 15Questions: 5Answers: 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: 10,288Questions: 25Answers: 2,347
    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

Sign In or Register to comment.