nikeshydav / jquery-datatables-editable

Automatically exported from code.google.com/p/jquery-datatables-editable
0 stars 0 forks source link

Uncaught ReferenceError: rowData is not defined #114

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Adding a new row
2.
3.

What is the expected output? What do you see instead?
Uncaught ReferenceError: rowData is not defined (on line 473)

What version of the product are you using? On what operating system?
jquery.dataTables.editable version 2.3.1
jqueryDataTables version 1.9.1
jquery version 1.7.1

Please provide any additional information below.

Original issue reported on code.google.com by tarif.ha...@gmail.com on 18 May 2012 at 6:44

GoogleCodeExporter commented 9 years ago
Issue persists with:
jquery.dataTables.editable version 2.3.2
jqueryDataTables.min version 1.9.3
jquery version 1.7.1

Deleting and updating rows work fine.

Original comment by dogbo...@gmail.com on 14 Aug 2012 at 10:19

GoogleCodeExporter commented 9 years ago
Replaced jquery.dataTables.min with version 1.9.0 from functioning 
demonstration at 
http://jquery-datatables-editable.googlecode.com/svn/trunk/addingrecords.html

Problem resolved.  Therefore the issue lies in something that has changed 
between 1.9.0 and 1.9.1 (and is still present in 1.9.3)

Original comment by dogbo...@gmail.com on 14 Aug 2012 at 10:31

GoogleCodeExporter commented 9 years ago
This appears to have happened when the fnTakeRowDataFromFormElements function 
was created.

I believe changing the following code at line 472 should fix thisL

FROM:
                    if (oSettings.aoColumns != null && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
                      rtn = oTable.fnAddData(rowData);
                    }
                    else {
                        rtn = oTable.fnAddData(values);
                    }

TO:
                        rtn = oTable.fnAddData(values);

The fnUpdateRowOnSuccess also references rowData (which now also calls 
fnTakeRowDataFromFormElements).
Around 

I believe changing FROM :
                if (oSettings.aoColumns != null
                                && oSettings.aoColumns[rel] != null
                                && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
                    sCellValue = values[oSettings.aoColumns[rel].mDataProp];
                } else {
                    sCellValue = values[rel];
                }

TO:
                if (oSettings.aoColumns != null
                                && oSettings.aoColumns[rel] != null
                                && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
                    sCellValue = rowData[oSettings.aoColumns[rel].mDataProp];
                } else {
                    sCellValue = values[rel];
                }

Original comment by j...@ofsystems.com on 23 Aug 2012 at 2:54

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I replaced the code referenced in comment 3 and was still having issues adding 
new rows.

I finally traced it down to the use of "mData" vs "mDataProp". mDataProp has 
been deprecated as of 1.9.2. (http://www.datatables.net/usage/columns) Using 
the new mData will make it incompatible with this plugin. Until an update has 
been made, you are limited to mDataProp.

Original comment by wchi...@vt.edu on 26 Sep 2012 at 7:07

GoogleCodeExporter commented 9 years ago
I used Comment 2 by dogbo...@gmail.com.  I think that fixed the error.
Can someone fix the code so it works with the current jquery.dataTables.js?

Original comment by ariceisn...@gmail.com on 12 Oct 2012 at 8:33

GoogleCodeExporter commented 9 years ago
I've the same problem with the vers.1.9.4.
I see that the fnUpdateRowOnSuccess is corrected, instead the first code
is yet wrong; the correct code is :

if (oSettings.aoColumns != null && 
isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
                       // rtn = oTable.fnAddData(rowData);// ERROR
            rtn = oTable.fnAddData(data);// CORRECT
                    }
                    else {
                        rtn = oTable.fnAddData(values);
                    }

Original comment by ilio2...@gmail.com on 12 Nov 2012 at 2:57

GoogleCodeExporter commented 9 years ago
I think I have a workaround that will fix the add row problem - I'm testing 
this against jquery.datatable.js v1.9.3

Original comment by todd.bra...@teamaol.com on 14 Dec 2012 at 7:22

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
#8 is working for me, but shouldn't it be...?

@@ -874,9 +875,12 @@
    //Deprecated
    sCellValue = sCellValue.replace("DATAROWID", iDT_RowId);
    sCellValue = sCellValue.replace(properties.sIDToken, iDT_RowId);
+
+   var prop = oSettings.aoColumns[rel].mDataProp !== undefined ? 
oSettings.aoColumns[rel].mDataProp : oSettings.aoColumns[rel].mData;
+
    if (oSettings.aoColumns != null
            && oSettings.aoColumns[rel] != null
-           && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
+           && isNaN(parseInt(prop))) {
-       rowData[oSettings.aoColumns[rel].mDataProp] = sCellValue;
+       rowData[prop] = sCellValue;
    } else {
        values[rel] = sCellValue;

Original comment by Sloa...@gmail.com on 12 Mar 2013 at 8:36

GoogleCodeExporter commented 9 years ago
Has this problem been fixed? I'm getting this error when trying to add row.

Original comment by riosteve...@gmail.com on 23 Jul 2014 at 5:48

GoogleCodeExporter commented 9 years ago
#8 worked for me in that the error no longer appears and I can add a row. But 
the row doesn't show up in the table without reloading the page.

Original comment by pkasar...@gmail.com on 25 Jul 2014 at 8:42

GoogleCodeExporter commented 9 years ago
problem persists through to version 2.3.3
answer 8 works beautifully to fix the issue and it does not require page reload

Original comment by ahids...@gmail.com on 12 Aug 2014 at 5:18