Jessima / jquery-datatables-editable

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

Doesn't use/set DT_RowId when get/updating data from an Ajax source #63

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use jquery.datatables, jquery.datatables.editable to create a table, and 
allow add, update, and select using AJAX
2. When returning values for select, set DT_RowId, as specified by 
jquery.datables.
3. Check the rendered HTML, and you will see that tr.id is equal to the first 
column in the returned data, rather than the contents of DT_RowID

What is the expected output? What do you see instead?

The <tr> rows generated should have an ID of the contents of DT_RowId.  Instead 
the ID is the contents of the first column in the row.

What version of the product are you using? On what operating system?

1.3, Windows XP.

Please provide any additional information below.

I think the problem code is:

$(oTable.fnGetNodes()).each(function () {
    var position = oTable.fnGetPosition(this);
    var id=oTable.fnGetData(position)[0];
    properties.fnSetRowID($(this), id);
}
);

And a potential fix is:

$(oTable.fnGetNodes()).each(function () {
    var position = oTable.fnGetPosition(this);
    var data = oTable.fnGetData(position);
    var id;
    if ( typeof data.DT_RowId != 'undefined' ) {
        id = data.DT_RowId;
    } else {
        id = data[0];
    }
    properties.fnSetRowID($(this), id);
}
);

I originally raised this issue on jquery.datatables website:

http://www.datatables.net/forums/discussion/comment/25655

Original issue reported on code.google.com by cs94...@gmail.com on 15 Sep 2011 at 12:43

GoogleCodeExporter commented 8 years ago
The problem seems to be only on updates.  I don't *think* adds are affected, 
but then it seems to call select afterwards anyway, so I *think* that solves 
the problem.

Original comment by cs94...@gmail.com on 15 Sep 2011 at 12:47

GoogleCodeExporter commented 8 years ago
Final comment - This problem is important, because when you are editing records 
on a second page, the rowId is the index of the record - but doesn't include a 
reference to the page.
So the rowId could equal '2', even though the user is browsing the 3rd page.  
So you need to have a valid DT_RowId sent to the sUpdateURL so that the correct 
row can be editted.

Original comment by cs94...@gmail.com on 15 Sep 2011 at 2:26

GoogleCodeExporter commented 8 years ago
I kind of got close to this issue (but solved it much more inelegantly) in 
http://code.google.com/p/jquery-datatables-editable/issues/detail?id=52

Original comment by aaron.we...@gmail.com on 15 Sep 2011 at 9:09

GoogleCodeExporter commented 8 years ago
Hi,

Could you please take the verison 1.3.4? In this verison is changed 
_fnSetRowIDInAttribute function so now it does notset id of the row if it 
alread has an id

        function _fnSetRowIDInAttribute(row, id) {
            if (row.attr("id") == null || row.attr("id") == "")
                row.attr("id", id);
        }

Original comment by joc...@gmail.com on 15 Sep 2011 at 9:32

GoogleCodeExporter commented 8 years ago
See examples on the 
http://jquery-datatables-editable.googlecode.com/svn/trunk/ajax_mDataProp.html 
and 
http://jquery-datatables-editable.googlecode.com/svn/trunk/ajax_object_source.ht
ml. Id is not overwritten anymore

Original comment by joc...@gmail.com on 15 Sep 2011 at 10:17

GoogleCodeExporter commented 8 years ago

Original comment by joc...@gmail.com on 22 Sep 2011 at 8:39

GoogleCodeExporter commented 8 years ago
When you say version 1.3.4, do you mean the plugin version? The latest version 
of the plugin is 1.3 according to the downloads page. Have you released other 
updated versions of it?

Original comment by mali...@gmail.com on 16 Apr 2012 at 8:53

GoogleCodeExporter commented 8 years ago
Hi, 

In the description I have added:

"In this archive are packed some offline examples for the JQuery DataTables 
plugin version 1.3. In you environment you should use the latest version of 
plugin that is placed on the site."

Please use the latest version of plugin from the online examples. I'm not 
updating this archive each time I fix some bug or make some change.

Jovan

Original comment by joc...@gmail.com on 17 Apr 2012 at 10:54

GoogleCodeExporter commented 8 years ago
I realize this is an old thread, but for the benefit of others that have this 
issue. 

I just downloaded the latest version from the website, and still experienced 
this problem. Here is how I worked around this issue:

makeEditable({
      ......
      "fnSetRowID": function(row, id){
                                    if (row.attr("id") == null || row.attr("id") == ""){
                                          row.attr("id", id);
                                    }
                            }
      ......
})

Original comment by mikedavi...@gmail.com on 22 Aug 2013 at 10:19