Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

117
Views
Create Edit & Delete Button on DataTables using AJAX ruby on rails

I am using DataTables with Ruby On Rails.

have the datasource setup for AJAX but i am trying to add an Edit Button to edit any record individually I have the following code

      $('#table').DataTable({
          ajax: '/get_dataset',
          columns: [
              {data: "id", sortable: false, bVisible: false},
              {title: 'Supplier', data: 'supplier'},
              {title: 'UPC', data: 'upc_fixed'},
              {title: 'Product Code', data: 'product_code'},
              {title: 'Category', data: 'category'},
              {title: 'Description', data: 'description'},
              {title: 'Item Count', data: 'item_count'},
              {title: 'Manage',
                  mRender: function (data, type, row) {
                      return '<%= link_to "Edit", edit_product_path(1) %>'
                  }
              }
          ],
          pageLength: 25
      });

What i am having problems with is how to change the "1" in this line to be {data: "id"}

              {title: 'Manage',
                  mRender: function (data, type, row) {
                      return '<%= link_to "Edit", edit_product_path(1) %>'
                  }
              }

Example

9 months ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.