Multitable Initialisation

Multitable Initialisation

nilopharnilophar Posts: 8Questions: 0Answers: 0
edited March 2010 in General
hello,
I have one jsp page which includes drop-down list having options as all,first,second. when i initialise one by one table
there is no problem.But when I firstly select all and then first it shows error as' DataTables warning: Unable to re-initialise DataTable. Please use the API to make any configuration changes required'. why it is so??? and what would be the solution over it???
I have tried fnDraw() and making table to null,as options tried already,but the problem never solved.Please help me out as early as possible.

Thanks,
nilophar

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you show us your initialisation code? It sounds like you are calling $().dataTable() on the first table twice - which is why the warning is showing up (since you can't do this!).

    Allan
  • nilopharnilophar Posts: 8Questions: 0Answers: 0
    edited March 2010
    I am using jquery for detecting which item to be selected as:

    [code]
    function getSelectedValue() {
    var getvalues = null;
    if (!$("#items option:selected").length) {
    $("#items option[value='All']").attr('selected', 'selected');
    getvalues = $("#items").val();
    firstTable();
    secondTable();

    } else {
    getvalues = $("#items").val();
    oFirstTable = null;
    oSecondTable= null;


    if (getvalues == "First") {
    if (oFirstTable != null) {
    oFirstTable .fnDraw();
    return;
    }
    $("#firstTable").show();
    firstTable();


    }
    if (getvalues == "Second") {

    if(oSecondTable!=null)
    { oSecondTable.fnDraw();
    return; }

    $("#secondTable").show();
    secondTable();

    }
    if (getvalues == "All") {
    $("#firstTable").show();
    $("#secondTable").show();
    firstTable();
    secondTable();
    }
    }
    }

    //first and second table initialisation
    function firstTable() {
    oFirstTable= firstTable.dataTable( {
    "bPaginate" : true,
    "bProcessing" : true,
    "sPaginationType" : "full_numbers",
    "oLanguage" : {
    "sZeroRecords" : "No Results Found"
    },
    "bFilter" : false,
    "bInfo" : true,
    "bJQueryUI" : true,
    "iDisplayLength" : 25,
    "bLengthChange" : false,
    "bSort" : false,
    "aaData": [
    [ "First"],
    ]
    });
    }

    function secondTable() {
    oSecondTable= secondTable.dataTable( {
    "bPaginate" : true,
    "bProcessing" : true,
    "sPaginationType" : "full_numbers",
    "oLanguage" : {
    "sZeroRecords" : "No Results Found"
    },
    "bFilter" : false,
    "bInfo" : true,
    "bJQueryUI" : true,
    "iDisplayLength" : 25,
    "bLengthChange" : false,
    "bSort" : false,
    "aaData": [
    [ "Second"],
    ]
    });
    }
    [/code]

    If calling datatable twice is not possible how should i overcome from this problem??

    (*edited by Allan to add syntax highlighting - makes life that little bit easier :-) )
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    [code]
    oFirstTable = firstTable.dataTable( {
    [/code]
    Should that be:

    [code]
    oFirstTable = $("#firstTable").dataTable( {
    [/code]
    ?

    Given that firstTable() looks recursive at the moment.

    Can getSelectedValue() be called more than once? If so then I think that's the problem - you can't re-initialise a table, you need to use the API methods to get the information from the table - just like the alert says. If it's only called once, then I can't see a code path which would result in this error... (unless my above comment does the trick).

    Allan
  • nilopharnilophar Posts: 8Questions: 0Answers: 0
    Thanks for your reply first.
    i used fnDaw() method but it does not work,can you please suggest me which API method to be called to do so???
This discussion has been closed.