Dynamicall checkboxes with fnrender

Dynamicall checkboxes with fnrender

handbuchhandbuch Posts: 55Questions: 0Answers: 0
edited September 2010 in General
The solution is at the end. With scripts.


hi, im makign a table out of a json string.

http://pastebin.org/980924 here my code.

It works fine, but know i want some checkboxes. Then i want a string which gives me the vlaue of contact_id where i did check the checkbox. so i can use it for deleting/editing the entries with php.

and how can i hide the contact id?

So how do i add a checkbox which gives me the contact id value?

thanks a lot

Replies

  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    I got it now like that, but that doesnt work. i see the checkboxes, but i dont get any return value. how can i return the contact_id?

    http://pastebin.org/985728
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    edited September 2010
    it "works" now. i noew need a loop when rendering the table, so i set the value="checked" and the name is == the contact_ID, how can i do a loop which does that?
  • cdaiglecdaigle Posts: 57Questions: 0Answers: 0
    The data from the row is provided in the fnRender function. Assuming the contact_id is in one of the columns for that row, oObj.aData[] will return the value. So when you construct your checkbox, you can set those values at the same time.

    See this page for more details: http://datatables.net/usage/columns#fnRender

    Alternatively you could consider using the fnDrawCallback function or the fnRowCallback one. More details here: http://datatables.net/usage/callbacks

    Hope this helps.
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    edited September 2010
    Yeah thanks, got it. I will provide my solution.

    PHP Script: http://pastebin.org/1017641

    I get a JSON String from my server.php Script read out of a MySQL DB. The important stuff is that the string is numeric and the objct is called aaData.

    And here how i draw the table. http://pastebin.org/1017664 oObj.AData is your array where you can get your data from.

    My html looks like that: http://pastebin.org/1017689

    Important is that you do some around the table.

    Ou and you easy get a string of your checked boxes liek that: http://pastebin.org/1017767

    Hope this helps someone.
  • maryjanmaryjan Posts: 2Questions: 0Answers: 0
    Hi handbuch!

    could you post your solution again please?

    your links are dead.

    Thanks!
This discussion has been closed.