locked
Jquery datatable RRS feed

  • Question

  • User1979860870 posted

    Hi

      How to add View/Delete options to below code in Jquery datatable

             {
                    "defaultContent": '<button id="btnEdit" type="submit"><i class="fa fa-pencil"></i></button>'
                }

    Thanks

    Saturday, May 29, 2021 3:42 PM

All replies

  • User-939850651 posted

    Hi jagjit saini,

         {
                    "defaultContent": '<button id="btnEdit" type="submit"><i class="fa fa-pencil"></i></button>'
                }

    Which part of these codes are you given? If it is the render part, I think you only need to modify <a> to <button> to achieve your requirements.

    $('#example').DataTable({
                    data:result,
                    columns: [
                        { data: "Code" },
                        { data: "Name" },
                        { data: "Street" },
                        { data: "City" },
                        { data: "State" },
                        { data: "Zip" },
                        { data: "Country" },
                        { data: "Panno" },
                        { data: "GstRegNo" },
                        { data: "Mobile" },
                        { data: "Phone_1" },
                        { data: "Phone_2" },
                        { data: "E_Mail" },
                        {
                            "data": null,
                            "render": function (value) {
                                return '<a href="#" onclick="return getbyID(' + value.Code + ')">Edit</a> | <a href="#" onclick="Delete(' + value.Code + ')">Delete</a>';
                            }
                        }
                    ]
               });

    If I misunderstood something, could you provide more details?

    Best regards,

    Xudong Peng

    Monday, May 31, 2021 10:12 AM