Using fnGetPosition to find a TR by id?

Using fnGetPosition to find a TR by id?

naspinskinaspinski Posts: 13Questions: 0Answers: 0
edited March 2009 in General
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?

Replies

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    edited April 2009
    Hi naspinski,

    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
  • naspinskinaspinski Posts: 13Questions: 0Answers: 0
    When I was messing around with it, I was able to use 'this'


    $("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 :)
  • andersanders Posts: 1Questions: 0Answers: 0
    allan, that ought to be:

    oTable.fnGetPosition( $("#row_61").get(0) );

    to get the DOM-element, right?
  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    Hi Anders,

    Oops - yes you are absolutely right. $("#row_61")[0] would do the trick as well. I've fixed my comment now. :-)

    Allan
  • akreiderakreider Posts: 33Questions: 0Answers: 0
    I'm having trouble getting this to work.

    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
  • akreiderakreider Posts: 33Questions: 0Answers: 0
    edited September 2009
    I'm thinking my DOM might be messed up?

    But I'm not getting any other errors in Firebug.
  • akreiderakreider Posts: 33Questions: 0Answers: 0
    Never mind. I think it is a single versus double quotes mistake. Oops!
This discussion has been closed.