1

Hi i have created the jquery datatable using below code..

The column email id and activated date is may be nullable. When i render the table it is showing 'Request unknown parameter 'email' from data source for row 0'

 var tblAllKeys = $('#tblAllKeys').dataTable({
                    "bDestroy" : true,
                    "bProcessing" : true,
                    "bServerSide" : true,
                    "bLenthChange" : false,
                    "iDisplayLength" : 10,
                    "sAjaxSource" : "loadAllKeys",
                    "oLanguage" : {
                        "sSearch" : "Search By Activation Key:"
                    },
                    "aoColumns" : [
                     {"sTitle" : "No.","mData" : null,"aTargets": [ 0 ],
                        "fnRender" : function(obj) {
                            var columnIndex = obj.oSettings._iDisplayStart + obj.iDataRow+1
                            return columnIndex;
                        }
                    },
                    {"sTitle" : "Activation Key","mData" : "key", "bSearchable" : true},
                    {"sTitle" : "Email ID","mData" :  "email" , "bSearchable" : false},
                    {"sTitle" : "App Edition","mData" : "edition", "bSearchable" : false},
                    {"sTitle" : "Batch Code","mData" : "batch", "bSearchable" : false},
                    {"sTitle" : "Activated Date","mData" : "aDate" , "bSearchable" : false},
                    {"sTitle" : "Generated Date","mData" : "gDate", "bSearchable" : false},
                    {"sTitle" : "Status","mData" : "status", "bSearchable" : false},
                    ],
                       "fnServerData" : function(sSource, aoData, fnCallback) {
                        $.ajax({
                         "dataType" : 'json',
                         "type" : "GET",
                         "url" : sSource,
                         "data" : aoData,
                         "success" : fnCallback
                        });
                       },
                       "sPaginationType" : "full_numbers",
                });
2
  • nullable or the column itself will not be present? Commented Nov 8, 2016 at 9:35
  • no column is present. only value is null Commented Nov 8, 2016 at 9:36

1 Answer 1

2

You can make use of columns.defaultContent option available as per their docs on this error, to display default value or empty string when column's doesn't have any value.

"aoColumns": [{
  "sTitle": "No.",
  "mData": null,
  "aTargets": [0],
  "fnRender": function(obj) {
    var columnIndex = obj.oSettings._iDisplayStart + obj.iDataRow + 1
    return columnIndex;
  }
}, {
  "sTitle": "Activation Key",
  "mData": "key",
  "bSearchable": true
}, {
  "sTitle": "Email ID",
  "defaultContent":"",//or specify any other value
  "mData": "email",
  "bSearchable": false
}, {
  "sTitle": "App Edition",
  "mData": "edition",
  "bSearchable": false
}, {
  "sTitle": "Batch Code",
  "mData": "batch",
  "bSearchable": false
}, {
  "sTitle": "Activated Date",
  "mData": "aDate",
  "bSearchable": false
}, {
  "sTitle": "Generated Date",
  "mData": "gDate",
  "bSearchable": false
}, {
  "sTitle": "Status",
  "mData": "status",
  "bSearchable": false
}, ],

Its good to assign defaultContent option to all the columns if you are sure that any of the column might come empty.

Sign up to request clarification or add additional context in comments.

6 Comments

Could you please try replicating it here with sample data?
Do you mean the response from server?
{"iTotalRecords":0,"iTotalDisplayRecords":0,"sEcho":2,"aaData":[{"key":"JPBFTU3Q1MOY","edition":"Professional Edition","batch":"PROMOTIONAL TRIAL KEYS 1","gDate":"05/11/2016","status":"Unsubscribed"}]}
Your aaData does not contain email id column?
I think i know what the issue is. i'm not sending email from server.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.