Binding of grid is not happening properly. Please help!
Binding of grid is not happening properly. Please help!
javascript:
var fileinfo; //This is a string which gets filled by calling a ajax call.
function OnSuccess(response) {
fileinfo = response.d;
}
$('#example').DataTable({
data : fileinfo,
columns: [
{ title: "FileID" },
{ title: "RecordDetailsID" },
{ title: "ProductName" },
{ title: "HRI" },
{ title: "CheckNumber" },
{ title: "filename" },
{ title: "Recipinet_Name" },
{ title: "Mailing_Address" }
]
});
aspx page:
FileID | RecordDetailsID | ProductName | HRI | CheckNumber | filename | Recipinet_Name | Mailing_Address |
---|---|---|---|---|---|---|---|
FileID | RecordDetailsID | ProductName | HRI | CheckNumber | filename | Recipinet_Name | Mailing_Address |
Answers
Above is the way how grid is loaded. Kindly help
Hi @Satya Karthik,
We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
HI Colin,
Thanks for replying.
Below is the link:
http://live.datatables.net/subepofa/1/
But here i cannot provide data as it is retrieved from Database
But i'm sharing the data available in variable fileinfo which is used in javascript to bind datatable.
{
"FileID": 2521,
"RecordDetailsID": 64390,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "THERESA LYNN PELLOW",
"Mailing_Address": "6320 REDWOOD COURT CLARKSVILLE TN 37040",
"FileID": 2521,
"RecordDetailsID": 64391,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "HOUDINI HOED",
"Mailing_Address": "14043 US HWY 278 WEST OGDENSBURG NY 13669",
"FileID": 2521,
"RecordDetailsID": 64392,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "JEFF SR LYLES",
"Mailing_Address": "733 CAMBRIDGE ROCHESTER NY 14626",
"FileID": 2521,
"RecordDetailsID": 64393,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "LAVEL HUEMPFNER",
"Mailing_Address": "1413 SMITHERS AVE SOUTH 511 GREENBRIAR LN",
"FileID": 2521,
"RecordDetailsID": 64394,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "ROMALLIS VARELA",
"Mailing_Address": "1706 YORKSTOWN DR WILLIAMSTOWN KY 41097",
"FileID": 2521,
"RecordDetailsID": 64395,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "ANUA FETICK",
"Mailing_Address": "1081 BOYER TINTON FALLS NJ 07724",
"FileID": 2521,
"RecordDetailsID": 64396,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "TONYJR STEHMAN",
"Mailing_Address": "214 BRIARGATE DRIVE PLANTATION FL 33325",
"FileID": 2521,
"RecordDetailsID": 64397,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "CARMELITTA LAWYER FAMILY",
"Mailing_Address": "10346 TRIPLE CROWN AVE THORNTON CO 80229",
"FileID": 2521,
"RecordDetailsID": 64398,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "RONALD D BIRKENMIER",
"Mailing_Address": "6125 FESCUE DRIVE NAPLES FL 34117",
"FileID": 2521,
"RecordDetailsID": 64399,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "DALAN PASNIK",
"Mailing_Address": "727 PUEBLO WAY LINWOOD MA 01525",
"FileID": 2521,
"RecordDetailsID": 64400,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "KOEI KUKWA",
"Mailing_Address": "R.R. #10 SOUTH 36TH STREE LYNCHBURG OH 45142"
}
Kindly look into it and respond
I am getting below error message when the solution is ran:
DataTables warning: table id=example - Requested unknown parameter 'FileID' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
I even looked into above link for any solution, but didn't find any.
Your data is not in a format supported by Datatables. You need an array of objects as described here:
https://datatables.net/manual/data/#Data-source-types
Kevin
Hi Kevin,
thanks for the response.
now i am returning array. but still getting error.
{[
[
"FileID": 2521,
"RecordDetailsID": 64390,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "THERESA LYNN PELLOW",
"Mailing_Address": "6320 REDWOOD COURT CLARKSVILLE TN 37040"
],
[
"FileID": 2521,
"RecordDetailsID": 64391,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "HOUDINI HOED",
"Mailing_Address": "14043 US HWY 278 WEST OGDENSBURG NY 13669"
],
[
"FileID": 2521,
"RecordDetailsID": 64392,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "JEFF SR LYLES",
"Mailing_Address": "733 CAMBRIDGE ROCHESTER NY 14626"
],
[
"FileID": 2521,
"RecordDetailsID": 64393,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "LAVEL HUEMPFNER",
"Mailing_Address": "1413 SMITHERS AVE SOUTH 511 GREENBRIAR LN"
],
[
"FileID": 2521,
"RecordDetailsID": 64394,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "ROMALLIS VARELA",
"Mailing_Address": "1706 YORKSTOWN DR WILLIAMSTOWN KY 41097"
],
[
"FileID": 2521,
"RecordDetailsID": 64395,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "ANUA FETICK",
"Mailing_Address": "1081 BOYER TINTON FALLS NJ 07724"
],
[
"FileID": 2521,
"RecordDetailsID": 64396,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "TONYJR STEHMAN",
"Mailing_Address": "214 BRIARGATE DRIVE PLANTATION FL 33325"
],
[
"FileID": 2521,
"RecordDetailsID": 64397,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "CARMELITTA LAWYER FAMILY",
"Mailing_Address": "10346 TRIPLE CROWN AVE THORNTON CO 80229"
],
[
"FileID": 2521,
"RecordDetailsID": 64398,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "RONALD D BIRKENMIER",
"Mailing_Address": "6125 FESCUE DRIVE NAPLES FL 34117"
],
[
"FileID": 2521,
"RecordDetailsID": 64399,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "DALAN PASNIK",
"Mailing_Address": "727 PUEBLO WAY LINWOOD MA 01525"
],
[
"FileID": 2521,
"RecordDetailsID": 64400,
"ProductName": "J011D09",
"CheckNumber": "",
"filename": "HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1",
"Recipient_Name": "KOEI KUKWA",
"Mailing_Address": "R.R. #10 SOUTH 36TH STREE LYNCHBURG OH 45142"
]
]}
Getting below error:
DataTables warning: table id=example - Requested unknown parameter 'FileID' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
The "JSON" you just posted isn't valid JSON. Copy and paste it into JSONLint.
Allan
That is not a valid JSON string not Javascript variable. You can validate your JSON strings here:
https://jsonlint.com/
It should look more like this:
This is an array with multiple objects. If
fileinfo = response.d;
is a JSON string you will need to useJSON.parse()
to convert it to a Javascript array.Kevin
Hi Kevin,
I have used JSON.stringify(response.d).
and verified the output in https://jsonlint.com/, which resulted as valid json.
below is json returned after stringify:
[[{"Value":2521,"Name":"FileID"},{"Value":64390,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"THERESA LYNN PELLOW","Name":"Recipient_Name"},{"Value":"6320 REDWOOD COURT CLARKSVILLE TN 37040","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64391,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"HOUDINI HOED","Name":"Recipient_Name"},{"Value":"14043 US HWY 278 WEST OGDENSBURG NY 13669","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64392,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"JEFF SR LYLES","Name":"Recipient_Name"},{"Value":"733 CAMBRIDGE ROCHESTER NY 14626","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64393,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"LAVEL HUEMPFNER","Name":"Recipient_Name"},{"Value":"1413 SMITHERS AVE SOUTH 511 GREENBRIAR LN","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64394,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"ROMALLIS VARELA","Name":"Recipient_Name"},{"Value":"1706 YORKSTOWN DR WILLIAMSTOWN KY 41097","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64395,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"ANUA FETICK","Name":"Recipient_Name"},{"Value":"1081 BOYER TINTON FALLS NJ 07724","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64396,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"TONYJR STEHMAN","Name":"Recipient_Name"},{"Value":"214 BRIARGATE DRIVE PLANTATION FL 33325","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64397,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"CARMELITTA LAWYER FAMILY","Name":"Recipient_Name"},{"Value":"10346 TRIPLE CROWN AVE THORNTON CO 80229","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64398,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"RONALD D BIRKENMIER","Name":"Recipient_Name"},{"Value":"6125 FESCUE DRIVE NAPLES FL 34117","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64399,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"DALAN PASNIK","Name":"Recipient_Name"},{"Value":"727 PUEBLO WAY LINWOOD MA 01525","Name":"Mailing_Address"}],[{"Value":2521,"Name":"FileID"},{"Value":64400,"Name":"RecordDetailsID"},{"Value":"J011D09","Name":"ProductName"},{"Value":"","Name":"CheckNumber"},{"Value":"HRF_R1KNPB.OMS.CHECKS.NOPAY.OUTPUT_TEST_062718111514_DevFinal1","Name":"filename"},{"Value":"KOEI KUKWA","Name":"Recipient_Name"},{"Value":"R.R. #10 SOUTH 36TH STREE LYNCHBURG OH 45142","Name":"Mailing_Address"}]]
But still getting same error and output in UI.
Yes, its a valid JSON string. It still is not a structure that Datatables supports directly. You have an array of objects within an array. The inner work.
```
[
[{
"Value": 2521,
"Name": "FileID"
}, {
"Value": 64390,
"Name": "RecordDetailsID"
},
....
]
]
Either your server code needs to not put the array of objects in an array or you can access it using
response.d[0]
.Kevin