My select and checkbox rows are not showing the label data

My select and checkbox rows are not showing the label data

randy.johnsonrandy.johnson Posts: 18Questions: 8Answers: 0

In my example:
http://propane.randy1.com/randy

The Warehouse category column is showing the id instead of the actual text value I want it to show.

The Active column I would like to show Yes if the value is 1 and No if the value is 0

I thought this might give me some insight but it doesn't seem to help
http://datatables.net/reference/option/columns.data

What am I missing?

Thank You,

Randy

This question has an accepted answers - jump to answer

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited October 2015 Answer ✓

    The Warehouse category column is showing the id instead of the actual text value I want it to show.

    Well its showing exactly what you're telling it to show, You have the columns.data set to intWarehouseCategoryId, which when I look at your AJAX source, those are obviously numeric values.

    The Active column I would like to show Yes if the value is 1 and No if the value is 0

    For that, you would need to utilize the columnDefs option, something like this:

    columnDefs: [
        {
            targets: 3, // 3rd column
            data: null, // Use the full data source object for render src
            render: function ( data, type, row, meta ) {
                return data == '1' ? 'Yes' : 'No'; // If the value is 1, return 'Yes', otherwise return 'No'
            }
        }
    ]
    
  • randy.johnsonrandy.johnson Posts: 18Questions: 8Answers: 0

    Hello,

    I found this in the docs and it helped out greatly on my first issue.

    https://editor.datatables.net/examples/inline-editing/join.html

    And adding the columnDefs did the trick.

    Thank You so much. I have my first datatables and inline editing piece working.

    Randy

This discussion has been closed.