fnRender checkbox onclick function not being called

fnRender checkbox onclick function not being called

jnorrisjnorris Posts: 25Questions: 0Answers: 0
edited August 2010 in General
Hi All,

I'm using fnRender to add a checkbox to each row. Looking at the dom generated it looks correct to me:

[code]



[/code]

However, the function is not invoked which the checkbox is clicked (using an alert to test). Am I missing something obvious? I want to use the function to update the checked status for server-side processing.

Thanks,
Jim

Replies

  • jnorrisjnorris Posts: 25Questions: 0Answers: 0
    BTW I'm using version 1.7.0.
  • ruzzruzz Posts: 49Questions: 0Answers: 0
    edited August 2010
    Any errors reported anywhere? Firebug?

    I'm doing almost the same thing (in my case
  • jnorrisjnorris Posts: 25Questions: 0Answers: 0
    I've been doing all my testing on the server where the issue occurs with the onclick function. When I run the app on a remote machine the checkboxes work as expected. I don't have a clue why that is. Another weird thing is that all of the text in the div that contains the datatable displays in the normal font when run on the server, but it is all italisized in the remote browser. Unfortunately I'm adding jquery to a legacy system that has a lot of IE specific hacks so maybe that is causing something. I can't run in FF since it says aLayout[0] is undefined at line 5913. This is going to take some luck to figure it out.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm wondering if DOM0 events are actually followed by IE (and all other browsers) when added through innerHTML... I'm not sure to be honest. What you could do is use fnRowCallback ( http://datatables.net/usage/callbacks#fnRowCallback ) to add a jQuery event to the input element.

    Regarding " aLayout[0] is undefined at line 5913" - that is typically because the elements in the thead and tbody don't match. Perhaps you can post your HTML if that doesn't help.

    Allan
  • jnorrisjnorris Posts: 25Questions: 0Answers: 0
    Thanks for the reply Allen.

    The checkboxes work when connecting remotely so I'm not too concerned that they don't work when running a browser on the server. The fact that both of the tables render correctly in IE8 without the aLayout[0] error would indicate to me that the thead and tbody elements match. I have an empty tag in the basic markup and I have tried adding a dummy row which didn't help. The only error I see in FireBug when I open the page is the aLayout[0] error. Below is the relevant code/markup for one of the tables. Since the application is currently limited to running in IE anyway I'm not going to spend too much time on this issue but it would be nice for debugging ...

    Thanks,
    Jim

    [code]
    "aoColumns":
    [
    { "sName": "ID", "bVisible": false },
    {
    "sName": "",
    "sClass": "right",
    "bSortable": false,
    "fnRender": function( obj )
    {
    var sReturn;
    var id = obj.aData[0];
    if( obj.aData[ obj.iDataColumn ] == "Y" )
    sReturn = '';
    else
    sReturn = '';
    return sReturn;
    },
    "bUseRendered": false
    },
    { "sName": "Column 2", "sClass": "left" },
    { "sName": "Column 3", "sClass": "center" },
    { "sName": "Column 4", "sClass": "left" },
    { "sName": "Column 5", "sClass": "center" },
    { "sName": "Column 6", "sClass": "right" },
    { "sName": "Column 7", "sClass": "center" },
    { "sName": "Column 8", "sClass": "center" },
    {
    "sName": "Column 9",
    "sClass": "right",
    "fnRender": function( obj )
    {
    var id = obj.aData[ 0 ];
    var sReturn = "" + obj.aData[ obj.iDataColumn ] + "";
    return sReturn;
    },
    "bUseRendered": false
    }
    ],



    ID

    Column 2
    Column 3
    Column 4
    Column 5
    Column 6
    Column 7
    Column 8
    Column 9>




    [/code]
  • jnorrisjnorris Posts: 25Questions: 0Answers: 0
    I looked at the html here which was copied from an existing legacy table and see that the is missing from the tag. That solved the issue in Firefox!

    Jim
This discussion has been closed.