I want to Insert data in dataTable both Processing server side as well as Client side

I want to Insert data in dataTable both Processing server side as well as Client side

jigs9095jigs9095 Posts: 6Questions: 1Answers: 0
edited June 2020 in Free community support

my code is below

    function Edit(id) {
            if (confirm('Are Yous Sure To Edit Bill ?'))
            {
                $.ajax({
                    type: "GET",
                    url: '@Url.Action("Edit","Bill_Master")/' + id,
                    success: function (data) {
                        if (data.success) {
                             $('#Bill_No').attr('value', data.data.Bill_No);
                            $("#Party_Name").val(data.data.Party_Name);
                            $('#B_Sub').attr('value', data.data.SubTotal);
                            $('#B_Gst1').attr('value', data.data.Gstp);
                            $('#B_Gst').attr('value', data.data.Gstr);
                            $('#B_Remarks').attr('value', data.data.Remark);
                            $('#B_Grand').attr('value', data.data.GrandTotal);
                            $('#O_Contact').attr('value', data.data.Contact);
                            $('#A_GST').attr('value', data.data.A_Gst);
                            $("#Party_Name").change().trigger(data.data.Party_Name);
                        }
                    }
                });
                t = $('#GT').DataTable({
                    "bPaginate": false,
                    "bLengthChange": false,
                    "bFilter": false,
                    "bSort": false,
                    "bInfo": false,
                    "bAutoWidth": false,
                    'columnDefs': [
                        {
                            'targets': 5,
                            'data': null,
                            'searchable': false,
                            'orderable': false,
                            'defaultContent': '<button> Delete</button>'
                        }],
                     "columns": [
                                { "data": "OrderNo" },
                                { "data": "O_Media" },
                                { "data": "O_SqFeet" },
                                { "data": "O_Rate" },
                                { "data": "O_Total" },
                                ],
                     "ajax": {
                                "url": "/Bill_Master/GetOrder/"+id,
                                "type": "Get",
                                "datatype": "json"
                             },
                });
            }
        }

here i have already data in datatable
now i want to add new record data table
onbutton click new record add in data table

i have try t.add.row()

but its not working its give error like referance missing :https://datatables.net/manual/tech-notes/7

please help me out

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    The first step would be to follow the diagnostic steps in the link that's in the error message - that should get you going.

    If that doesn't help, 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

  • jigs9095jigs9095 Posts: 6Questions: 1Answers: 0

    i am not able to full code run in js fiddle, i am new in MVC so i dont know how to test code in JSFiddel so please if anybody can under stand what i actually want please help me out.

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394
    Answer ✓

    Did you do what Colin said?

    The first step would be to follow the diagnostic steps in the link that's in the error message

  • jigs9095jigs9095 Posts: 6Questions: 1Answers: 0

    no actually i dont understand what Colin said to do

  • kthorngrenkthorngren Posts: 20,143Questions: 26Answers: 4,736

    The error message provides the link https://datatables.net/manual/tech-notes/7 with initial troubleshooting steps. If you ar getting an Ajax error that usually means that the server had an error and is responding with something other than a 2XX status code. Likely you will need to review your server logs to find the problem.

    Kevin

  • jigs9095jigs9095 Posts: 6Questions: 1Answers: 0

    Thanks Kevin

    But i Want to add Data From server and then I will insert temporary record from textbox onclick button

  • kthorngrenkthorngren Posts: 20,143Questions: 26Answers: 4,736

    It looks like your edit() function in the code snippet above uses jQuery Ajax to fetch a Bill_Master by the ID and populate a form. Plus it fetches the same ID for the Datatable. Is this when you get the Ajax error?

    Datatables has an Editor extension you can purchase that will provide the client and server components to perform editing functions. Then you wan't have to code your own. If you want to code your own then it will be difficult to help without access to your code to see what is happening. If you are unable to provide a link to a test case showing the issues then you will need to provide more details and be very specific of any errors and what to look at in your code. The above code snippet isn't enough to help troubleshoot the issue.

    Kevin

  • jigs9095jigs9095 Posts: 6Questions: 1Answers: 0

    thanks kevin as you say first that actually happen with my code.

    but i don't know about editor pls help me figure out for this any example you have

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    This is a simple example using Editor - that may help do this more efficiently.

    Colin

  • jigs9095jigs9095 Posts: 6Questions: 1Answers: 0

    Thanks Colin,
    its very helpful for me

This discussion has been closed.