fnUpdate for a single cell with objects

fnUpdate for a single cell with objects

shanmugamshanmugam Posts: 2Questions: 0Answers: 0
edited March 2013 in General
i would like to update a cell with an object. but i am getting error while doing so by fnUpdate . Inside fnRowCallback function i will convert this object to a string and i will put this string in the column. please help me in this.

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Link to a test case showing the error please.

    Allan
  • shanmugamshanmugam Posts: 2Questions: 0Answers: 0
    The following line is causing the issue.
    var mapConfig = {};
    mapConfig["key1"] = "value1";
    oTable.fnUpdate(mapConfig,index-1,4);

    The error that i am getting is "DataTables warning (table id = 'resultsTable'): Requested unknown parameter '0' from the data source for row 0".

    if i pass a string in fnUpdate it accepts it.for example the following is working.
    oTable.fnUpdate(JSON.stringify(mapConfig),index-1,4);

    initially when i loaded the table i passed a map to aData[4] via ajax response. and inside the fnRowCallback i converted it to a string as given below.

    var string = '';
    var mapConfig = aData[4];
    for(var key in mapConfig ) {
    string += key;
    string += '=';
    string += mapConfig [key];
    }
    $('td:eq(4)', nRow).html(string);
    Everything was fine till this point. i stored the object in dataTable. only while loading the table i converted the object(map) to a string inside fnRowCallback for displaying purpose.

    My question is the dataTable was accepting a map object while loading it via sAjaxSource. but later when i try to update the stored map object using fnUpdate it is not working. How can i change the stored object. is there any workaround for this?

    thanks in advance.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    DataTables 1.9.4 should be able to handle the situation you describe. Which version are you using? Can you please link to a live test case so I can debug and fix it?
This discussion has been closed.