I want to add edit and delete buttons in datatables using codenigator

I want to add edit and delete buttons in datatables using codenigator . This is my controller code where i am displaying the data. Now i want to add buttons but can made the logic that how to print those buttons. I am using codeginator

public function dataa()
    {
        $draw = intval($this->input->get("draw"));
          $start = intval($this->input->get("start"));
          $length = intval($this->input->get("length"));
          $this->load->model('mymodel');
          $this->load->library('Datatables');
          $this->Datatables->add_column('edit','<a href="#">edit</a>');


          $record = $this->mymodel->records();

          $data = array();

          foreach($record->result() as $r) {

               $data[] = array(
                    $r->email,
                    $r->name,
                    $r->fathername,
                    $r->phone 
               );
          }

          $output = array(
               "draw" => $draw,
                 "recordsTotal" => $record->num_rows(),
                 "recordsFiltered" => $record->num_rows(),
                 "data" => $data

            );
          echo json_encode($output);
          exit();
    }

and this is my view

<script type="text/javascript">
$(document).ready(function() {
    $('#record-table').DataTable({
        "ajax": {
            url : "<?php echo site_url("mycontroller/dataa") ?>",
            type : 'GET'
        },

    });
});
</script>

you can also try this in your code:

foreach($record->result() as $r) {

           $data[] = array(
                $r->email,
                $r->name,
                $r->fathername,
                $r->phone ,
                "<a href='#'>edit</a>"

           );
      }

I want to add edit and delete buttons in datatables using codenigator, I want to add edit and delete buttons in datatables using codenigator . This is my controller code where i am displaying the data. Now i want to add buttons but  DataTables in Codeigniter ( Add Edit and Delete Buttons ) Add Edit record using JQuery DataTable plugin in ASP.NET MVC application Insert Update Delete View in Codeigniter [View data]

I think this might be useful

in your Controller

if (!empty($record->result())) {
        foreach ($record->result() as $r) {
            $nestedData['email'] = $r->emailemail;
            $nestedData['name'] = $r->name;
            $nestedData['fathername'] = $r->fathername;
            $nestedData['phone'] = $r->phone;
            $nestedData['action'] = "<a href='#'></a>";

            $data[] = $nestedData;
        }
    }

    $json_data = array(
        "draw" => intval($this->input->post('draw')),
        "recordsTotal" => intval($totalData),
        "recordsFiltered" => intval($totalFiltered),
        "data" => $data
    );

    echo json_encode($json_data);

and in view:

<script type="text/javascript">
    $(document).ready(function() {
        $('#record-table').DataTable({
            "ajax": {
                url : "<?php echo site_url("mycontroller/dataa") ?>",
                type : 'POST'
            },
            columns: [
                        {data: "email"},
                        {data: "name"},
                        {data: "fathername"},
                        {data: "phone"},
                        {data: "action"},
                    ],

        });
    });
    </script>

Jquery datatable edit row button, I want to add edit and delete buttons in datatables using codenigator . This is my controller code where i am displaying the data. Now i want to  CRUD Application Example Using Codeigniter and MySQL. Below is step by step process to create listing, add, edit and delete record using Codeigniter and MySQL, In earlier codeigniter tutorials, I have created connection configuration and enable library into bootstrap file.

Add another column to your table for your edit and delete button. (ex. action column). just match the number of columns to the number of data inside your $data variable

$data = array();

          foreach($record->result() as $r) {

               $data[] = array(
                    $r->email,
                    $r->name,
                    $r->fathername,
                    $r->phone,
                    '<a href="#">edit</a>',
                    '<a href="#">delete</a>'
               );
          }

Jquery datatable edit row button, How do I add button on each row in datatable? Ask Question Asked 5 years, I want to add edit and delete buttons in datatables using codenigator. This software  In this tutorial you will learn about jQuery Datatables Add, Read, Edit, Delete, Export and Custom Filter Using Codeigniter with Ajax. We will handle to refresh Datatables when any record updated or delete from table. This is a very simple example, you can just copy paste and change according to your requirement.

you can add helper database_helper

function callback_delete($id)
{
   return "<button class='btn btn-danger delete' data-
           id='{$id}'>Delete</button>";
}

function callback_edit($id)
{
    return "<button class='btn btn-primary edit' data-id='{$id}' data-
           toggle='modal' data-target='#editInsertmodal'>Edit</button> 
           ";
}

and call like this in controller

public function get_user()
{
    $this->load->helper('database');
    $this->datatables-
>select('user_id,user_firstname,user_lastname,user_email')
        ->from('users')
        ->add_column('Edit','$1','callback_edit(user_id)')
        ->add_column('Delete','$1','callback_delete(user_id)');

    echo $this->datatables->generate();
}

display data using ajax datatable with codeigniter – GiveMeAns , If you need to handle row selection with checkboxes with jQuery DataTables, consider I am using AJAX technology to add,edit and delete records with mysql​. 5 years, I want to add edit and delete buttons in datatables using codenigator. This is one more post on Codeigniter Ajax Crud using DataTables, In this part we will learn how to update or edit Mysql table data in Codeigniter Framework by using Ajax method and load data in DataTables Jquery plugin without page refresh.

Add button in datatable jquery, I want to display data from database in my view using ajax. I want to add edit and delete buttons in datatables using codenigatorIn "PHP". How would I go about placing edit and delete button on each row rather than on the top of the page and where is this code usually placed? If you want to get

Top Questions, Dynamically Add Rows to GridView using jQuery on Button Click in I want to add edit and delete buttons in datatables using codenigator. I want to add edit and delete buttons in datatables using codenigator . This is my controller code where i am displaying the data. Now i want to add buttons but can made the logic that how to print

javascript, Password. By registering, you agree to the privacy policy and terms of service. I want to add edit and delete buttons in datatables using codenigator · javascript  By Codewife.com codeigniter datatables with searching and pagination with edit delete options how to create datatables in codeigniter php Live Table Add Edit Delete using Ajax Jquery in

Comments
  • Not that what i want i am using codeigator
  • Possible duplicate of How do I add button on each row in datatable?
  • no thats not helping
  • gives me that error Failed to load resource: the server responded with a status of 500 (Internal Server Error) /favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)
  • Its not loading my data
  • Error in response to storage.get: TypeError: Cannot read property '1' of null at getWebspeed (chrome-extension://pgjjikdiikihdfpoppgaidccahalehjh/webspeed.js:83:72) at Object.chrome.storage.local.get [as callback] (chrome-extension://pgjjikdiikihdfpoppgaidccahalehjh/webspeed.js:95:31) at Object.callback (chrome-extension://pgjjikdiikihdfpoppgaidccahalehjh/webspeed.js:94:29) jquery.min.js:2 POST ziksoft.com/task2/mycontroller/dataa 500 (Internal Server Error)
  • @QadeerMalik If you are using google chrome as browser, you can check developer tools. Go to network tab. refresh your page first then try to load the page where the datatable should be load. It will show the error/response
  • try to remove this line$this->Datatables->add_column('edit','<a href="#">edit</a>'); , Have you add another column for your edit and delete button?. just like for email,name, etc
  • DataTables warning: table id=record-table - Requested unknown parameter 'email' for row 0, column 0. For more information about this error, please see datatables.net/tn/4