From aaf9697bd6294a372fea49da55ee4ba19024da7e Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 21 Jun 2011 18:38:00 +0100 Subject: [PATCH] Fix: The ability to use complex data structures in 1.8 means that arrays which are passed into to fnUpdate need not strictly be the same length as the number of columns in the table - therefore the warning that is given if you do this is wrong... no other code changes needed - just no need to generate the warning! Unit test added - 5396 --- media/js/jquery.dataTables.js | 7 -- .../1_dom/5396-fnUpdate-arrays.js | 103 ++++++++++++++++++ 2 files changed, 103 insertions(+), 7 deletions(-) create mode 100755 media/unit_testing/tests_onhold/1_dom/5396-fnUpdate-arrays.js diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 6cae6c4a..e8da90d8 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -1926,13 +1926,6 @@ if ( $.isArray(mData) && typeof mData == 'object' ) { /* Array update - update the whole row */ - if ( mData.length != oSettings.aoColumns.length ) - { - _fnLog( oSettings, 0, 'An array passed to fnUpdate must have the same number of '+ - 'columns as the table in question - in this case '+oSettings.aoColumns.length ); - return 1; - } - oSettings.aoData[iRow]._aData = mData.slice(); for ( i=0 ; i6' ); + $('#example thead tr').append( '7' ); + $('#example thead tr').append( '8' ); + $('#example thead tr').append( '9' ); + $('#example thead tr').append( '10' ); + + var aDataSet = [ + [ + "1", + "홍길동", + "1154315", + "etc1", + [ + [ "test1@daum.net", "2011-03-04" ], + [ "test1@naver.com", "2009-07-06" ], + [ "test4@naver.com", ",hide" ], + [ "test5?@naver.com", "" ] + ], + "2011-03-04", + "show" + ], + [ + "2", + "홍길순", + "2154315", + "etc2", + [ + [ "test2@daum.net", "2009-09-26" ], + [ "test2@naver.com", "2009-05-21,hide" ], + [ "lsb@naver.com", "2010-03-05" ], + [ "lsb3@naver.com", ",hide" ], + [ "sooboklee9@daum.net", "2010-03-05" ] + ], + "2010-03-05", + "show" + ] +] + + var oTable = $('#example').dataTable({ + "aaData": aDataSet, + "aoColumns": [ + { "mDataProp": "0"}, + { "mDataProp": "1"}, + { "mDataProp": "2"}, + { "mDataProp": "3"}, + { "mDataProp": "4.0.0"}, + { "mDataProp": "4.0.1"}, + { "mDataProp": "4.1.0"}, + { "mDataProp": "4.1.1"}, + { "mDataProp": "5"}, + { "mDataProp": "6"} + ] + }); + + + oTest.fnTest( + "Initialisation", + null, + function () { + return $('#example tbody tr:eq(0) td:eq(0)').html() == '1'; + } + ); + + oTest.fnTest( + "Update row", + function () { + $('#example').dataTable().fnUpdate( [ + "0", + "홍길순", + "2154315", + "etc2", + [ + [ "test2@daum.net", "2009-09-26" ], + [ "test2@naver.com", "2009-05-21,hide" ], + [ "lsb@naver.com", "2010-03-05" ], + [ "lsb3@naver.com", ",hide" ], + [ "sooboklee9@daum.net", "2010-03-05" ] + ], + "2010-03-05", + "show" + ], 1 ); + }, + function () { + return $('#example tbody tr:eq(0) td:eq(0)').html() == '0'; + } + ); + + oTest.fnTest( + "Original row preserved", + null, + function () { + return $('#example tbody tr:eq(1) td:eq(0)').html() == '1'; + } + ); + + + + oTest.fnComplete(); +} ); \ No newline at end of file