record id with server-side

record id with server-side

talipskitalipski Posts: 3Questions: 0Answers: 0
edited April 2011 in General
looking for some guidance...

I have a mysql customer's table.. with a record_id index. All I want to do is when I click/dblclick on a row bring up the record_id of that row from mysql table. I would prefer to have the record_id hidden as say the id element of the tr but I couldn't get that to work. So I tried just displaying it as a column named customer ID and I can't get that to work either... I know I am missing something simple here but I just cant figure it out. Ultimately I would like when I doubleclick on the row the next page would come up with the customer info (based on the record_id)... for right now I am just trying to get an alert with the record_id displaying...

If I am going about this the wrong way please let me know...

Replies

  • AlawrenceAlawrence Posts: 18Questions: 0Answers: 0
    If I understand you correctly you are just trying to create a link to a data page within each row. So for example if I click Customer ID 123456789 for John Doe it opens a page with his information. If this is what you are attempting a simple way to accomplish it would be to simply create a link in your output with the variable in GET. This will produce a clickable ID which would pass the variable by URL to the data page where it could be retrieved. Another option would be to actually contain the information in the row but hide it using this example http://www.datatables.net/examples/api/row_details.html.
  • talipskitalipski Posts: 3Questions: 0Answers: 0
    Kind of what I am looking for... What I am really looking for is a way to ad the "id" of the record as the id of say the tr element. Then with a click or dblclick event on any part of the row would bring up the details page for that record. I have programmed for a quite a few years in php but now I am trying to integrate more and more jquery/ajax/css and I am still learning... so I am not sure if I am just screwing up the coding in general or am I going about it the wrong way for jquery.

    Anyway thanks for your input I am going to check out those examples and see if I can figure this out...
  • talipskitalipski Posts: 3Questions: 0Answers: 0
    okay after some more searching I figured it out...
    I returned my record id as a hidden column then used fnRowCallback in the following code to add the record id as the row id.
    [code]
    "fnRowCallback": function (nRow, aData) {
    $(nRow).attr("id",aData[0]);
    return nRow;
    },
    [/code]
    then used a live click event as follows to display the record id...
    [code]
    $('#customer_table tbody tr').live('click', function () {
    var cust_id = $(this).attr('id');
    alert(cust_id);
    });
    [/code]
    I am not sure if this is the most efficient way to do what I want but it gets the job done.
    thanks for all your help...
This discussion has been closed.