What's the difference between data and name in a column spec?

What's the difference between data and name in a column spec?

BasementjackBasementjack Posts: 19Questions: 7Answers: 0
edited July 2015 in DataTables 1.10

Hello everyone!

I have a script as seen below,
The field name is 'Company_ID' is the below script valid?
(Note that I've called the 'name' 'Company ID' with no space)

I'm trying to understand if an error I'm getting is because I'm using it wrong, or if it's a problem with the laravel datatables plugin I'm using.
Thanks!

<script>
    $(document).ready(function () {
        $('#trucks-table').DataTable({
            processing: true,
            serverSide: true,
            ajax: '{{ url("admin/trucks/data") }}',
            columns: [
                {data: 'Company_ID', name: 'Company ID'},
               ]
        });
    })
  • Jack

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    data: 'Company_ID'

    Perfectly valid.

    Generally speaking the columns.name property can be more or less ignored as it is really only used for selectors. The laravel DataTables plug-in might be doing something clever with it, but I'm afraid I haven't used that plugin.

    I assume you are getting an error - what is that error?

    Allan

  • BasementjackBasementjack Posts: 19Questions: 7Answers: 0

    The error was on the laravel side -
    I had a field named Company_ID and in the select statement it used that field, but then tried to do an Order by "Company ID" (using the name value instead of the data value)

    I suspect it's an inconsistency on the laravel plug in side.

This discussion has been closed.