Requested unknown parameter '0' from the data source fro row 0

Requested unknown parameter '0' from the data source fro row 0

victoreadwardvictoreadward Posts: 7Questions: 0Answers: 0
edited September 2013 in General
Hi folks, I am newbie in datatables.

I am trying to bind this JSON:

[code]{"cores":[{"dataDir":"/SOLR/solr/cores/simm_empresa/data/","index":{"current":"true","hasDeletions":"false","lastModified":"Sun Sep 15 11:21:46 BRT 2013","maxDoc":"27008244","numDocs":"27008244","optimized":"true","version":"1379196363885"},"instanceDir":"/SOLR/solr/cores/simm_empresa/","name":"simm_empresa","startTime":"Tue Sep 17 13:56:22 BRT 2013","uptime":"11842551"}]}[/code]

However, my table does not render properly and I got this message. My html code is:
[code]
<!--
<>1379196363885
-->


Name Instance Dir Data Dir Start Time Uptime
Current Has Deletions Last Modified Max Doc Num Docs Optimized
Version




name instanceDir dataDir 1 1 Object
false false last modified 1 1 false
1


[/code]

My init code:
[code]$('#coresTable').dataTable({
'sDom': '<\'row\'<\'span6\'<\'dt_actions\'>l><\'span6\'f>r>t<\'row\'<\'span6\'i><\'span6\'p>>',
'sPaginationType': 'bootstrap_alt',
'bProcessing': true,
'bServerSide': true,
'sAjaxDataProp': 'cores',
'sAjaxSource': 'http://localhost:8080/solrmonitor/service/cores/list',
'oLanguage': {
"sLengthMenu": '_MENU_ lines per page'
}

});[/code]

Please, any idea, how could I to sove this issue?

Thanks in advance.

Replies

  • fearednerdfearednerd Posts: 44Questions: 0Answers: 0
    Not 100% sure what the issue is but I see that your table header and the table data do not match up.
    Also do you need table data in the dom if you are using ajaxsource?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited September 2013
    The JSON uses objects for the data for each row, so you have to use mData to tell DataTables which property to use for each column, since otherwise DataTables can't know that information.

    Allan
  • victoreadwardvictoreadward Posts: 7Questions: 0Answers: 0
    Hi, I have updated my table script:

    [code]
    $('#coresTable').dataTable({
    'sDom': '<\'row\'<\'span6\'<\'dt_actions\'>l><\'span6\'f>r>t<\'row\'<\'span6\'i><\'span6\'p>>',
    'sPaginationType': 'bootstrap_alt',
    'bProcessing': true,
    'bServerSide': true,
    'sAjaxDataProp': 'cores',
    'sAjaxSource': 'http://localhost:8080/solrmonitor/service/cores/list',
    'aoColumns': [
    {'mData': 'name'},
    {'mData': 'instanceDir'},
    {'mData': 'dataDir'},
    {'mData': 'startTime'},
    {'mData': 'uptime'},
    {'mData': 'index.0'},
    {'mData': 'index.1'},
    {'mData': 'index.2'},
    {'mData': 'index.3'},
    {'mData': 'index.4'},
    {'mData': 'index.5'},
    {'mData': 'index.6'}
    ],
    'oLanguage': {
    "sLengthMenu": '_MENU_ linhas por página'
    }

    });
    [/code]

    And I also removed the html markup to the table data. The issue remains.

    My table has 29 EMPTY rows. 29 is the result set size.

    Notice that the item index at the JSON is an array. I tried to refer to it in mData like script above. Could it be the problem?
  • victoreadwardvictoreadward Posts: 7Questions: 0Answers: 0
    Someone, please!! Everything it is okay, except this.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Looks like it should work to me - can you please link to a test case so we can debug it and offer some assistance.

    Allan
  • victoreadwardvictoreadward Posts: 7Questions: 0Answers: 0
    It works! I replaced mData by mDataProp, and voilà. Thank you anyway.
  • victoreadwardvictoreadward Posts: 7Questions: 0Answers: 0
    apropos, congratulations. Datatables save time, mind, and... no stress.

    Thank you so much!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    mData was introduced in v1.9.4 - the current version. Before that it was called mDataProp :-).

    Allan
This discussion has been closed.