Using fnGetPosition to find a TR by id?
Using fnGetPosition to find a TR by id?
First of all, this plugin is genius! Thank you very much.
Now to my question. In the API section, it shows how to find a an element with 'this', but I am trying to find one by row id.
I tried stuff like this:
oTable.fbGetPosition("tr[id='row_61']:first");
-and-
oTable.fbGetPosition("#row_61");
but they aren't seeming to work - how can you select a row by using the ID? is there a way?
Now to my question. In the API section, it shows how to find a an element with 'this', but I am trying to find one by row id.
I tried stuff like this:
oTable.fbGetPosition("tr[id='row_61']:first");
-and-
oTable.fbGetPosition("#row_61");
but they aren't seeming to work - how can you select a row by using the ID? is there a way?
This discussion has been closed.
Replies
Thanks for the kind words!
The fnGetPosition() API function takes a single node as a parameter, so you first need to obtain that target node and then pass it in (rather than passing in the node's selector. For example:
[code]
oTable.fnGetPosition( $("#row_61")[0] ); /* jQuery selector */
/* or */
oTable.fnGetPosition( document.getElementById("row_61") ); /* Native method - faster for a single id */
[/code]
In this way you can get the position of any element in the table.
Regards,
Allan
$("td[id^='del_']").addClass("pointer").click(function(event) {
var pos = oTable.fnGetPosition(this);
var del = $(this);
$.ajax({
type: "POST",
url: "ajax_functions/delete.aspx",
data: "person_id=" + del.attr('id').replace('del_', ''),
success: function() {
$("#report").addClass("success").html("Person Deleted");
oTable.fnDeleteRow(pos[0]);
}
});
});
I have been putting together some ajax tutorials with asp.net ('asp.net ajax' - the built in framework, is atrocious IMO) that use your plugin at http://naspinski.net and I am really impressed with the versatility of this thing!
I have also been using it on the development of my new site and it is working out great!
I think it's time to hit the 'donation' button :)
oTable.fnGetPosition( $("#row_61").get(0) );
to get the DOM-element, right?
Oops - yes you are absolutely right. $("#row_61")[0] would do the trick as well. I've fixed my comment now. :-)
Allan
I have a row with an id='iFacilityid_67315'
$('#iFacilityid_67135').get(0)) - is undefined.
Any ideas?
This is what the html is for the row...
Wheelabrator Baltimore Refuse
But I'm not getting any other errors in Firebug.