update a column

update a column

dsr_22dsr_22 Posts: 2Questions: 0Answers: 0
edited July 2012 in DataTables 1.9
i want update a row, and update all data's 'isoCountryNm'
so i put fnUpdate in a "for" , it works fine in chrome , but in IE8 the code will become slow and a dialog show a message to inform me stop the script, if i select no, program will continue , if select yes, program will stop

[code]
var allData = oTable.fnSettings().aoData;
for(var i = 0; i < allData.length; i++) {

if (isoCountryNm == allData[i]._aData["isoCountryNm"])
{
oTable.fnUpdate(updatedCountryNm , i, 2);
}
}
[/code]

so i think another way to solve the problem

[code]

var allData = oTable.fnSettings().aoData;
for(var i = 0; i < allData.length; i++){
if(isoCountry2charCD == allData[i]._aData["isoCountry2charCD"]){
allData[i]._aData["isoCountryNm"] = updatedCountryNm;
}
}

oTable.fnDraw();

[/code]

but it is not work. i change the aoData but the page is not reDraw. I also try oTable.fnStandingRedraw() it is not work .

er... how can i update a column ?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Use fnUpdate as you had in your first example, but tell it not to redraw the table every time (that does a full resort and refilter) as it is very slow. Then at the end of the loop call fnDraw like in your second code example.

    [code]
    var allData = oTable.fnSettings().aoData;
    for(var i = 0; i < allData.length; i++) {

    if (isoCountryNm == allData[i]._aData["isoCountryNm"])
    {
    oTable.fnUpdate(updatedCountryNm , i, 2, false, false);
    }
    }

    oTable.fnDraw();
    [/code]

    You couldn't have been much closer :-)

    Allan
  • dsr_22dsr_22 Posts: 2Questions: 0Answers: 0
    It works. Thank you very mush.

    Sean
This discussion has been closed.