http://datatables.net/tn/4 is persistent

http://datatables.net/tn/4 is persistent

kenrightskenrights Posts: 36Questions: 10Answers: 0

Hi Guys,

I got the check boxes working without any errors. Here it is in the live.datatables.

Here at home however, the table is loaded in via ajax which is different than populating the table via html as done in the live.datatables link provided. When I refresh my page, I get the alert box with "DataTables warning: table id=table_id - Requested unknown parameter 'checkBox' for row 2, column 0. For more information about this error, please see [http://datatables.net/tn/4](http://datatables.net/tn/4 "http://datatables.net/tn/4")". I click on 'ok' in the alert box and everything works fine. Still, I want to clear this warning.

Obviously, the checkbox column doesn't exist in the JSON data:

[
  {
    "tag_RowId": "0",
    "tagName": "orange",
    "description": "orange is a color and a fruit",
    "dateCreated": "1979/08/22",
    "creator": "Spelter",
    "assignedAmount": "2407"
  },
  { ... 

In the HTML, I have to include a blank header else I get errors:

    <thead>
      <tr>
          <th></th>  <!--  THIS HAS TO BE HERE ELSE I GET AN ERROR -->  
          <th>Tag</th>
          <th>Description</th>
          <th>Date Created</th>
          <th>Creator</th>
          <th>Assigned Amount</th>
      </tr>
    </thead>

.

In the js file, I have to include the below:

columns: [     // defines columns to display and tells ajax what data to slurp in from each column in table https://datatables.net/manual/ajax
      { data: 'checkBox' },  // have to have this line else, the tagname data is omitted but, column still displays.
      { data: 'tagName' },
      { data: 'description' },
      { data: 'dateCreated' },
      { data: 'creator' },
      { data: 'assignedAmount' },
    ],

If the above 'checkBox' line isn't included, I get this weird result where the tagname data is omitted but, the column header still appears. The data shifts to the left which makes the data show up under the wrong columns and the last column is empty:
.

With or without these additional 'checkbox' field lines below, it works the same:

fields: [    // Define the data to use for each column in the table
  /*{
    label:     "",
    name:      "checkBox"
  },*/
  {
    label: 'Tag Name:',
    name: 'tagName'
  },
  {

I tried using some of the code shown on the Permanent inline checkboxes page but, it didn't solve my problem. Does anyone see any suggestions ?

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765

    If the checkbox is not part of the JSON data then try using { data: null }, instead of { data: 'checkBox' }, as described in the columns.data docs.

    Like this:
    http://live.datatables.net/qovezemu/2/edit

    Kevin

  • kenrightskenrights Posts: 36Questions: 10Answers: 0

    thanks Kevin for giving it a shot. I tried { data: null }, instead of { data: 'checkBox' } and it didn't change the warning alert box.

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765

    You made that change and still get the Requested unknown parameter 'checkBox' for row 2, column 0. error?

    Row 2 is interesting. Normally it would be row 0. ITs hard to say what else could be the problem with the code snippets you show. Maybe you can post your full Datatbles init code along with the first few rows of the JSON response shown in the browser's developer tools.

    Kevin

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    As Kevin said, please send more code. Also, it would be worth doing a complete page refresh in case the old checkBox code is being cached.
    C

This discussion has been closed.