开发者

Using jeditable on datatables with tabs

开发者 https://www.devze.com 2023-03-31 20:04 出处:网络
I\'m new when it comes to datatables and jeditable. Right now I\'m trying do use jeditable on my datatables but it wont work all the way.

I'm new when it comes to datatables and jeditable. Right now I'm trying do use jeditable on my datatables but it wont work all the way. My problem: When i switch tab in my datatable, the jeditable event doesnt follow to the new tab so I can't edit any cell. The first tab is the only one where I can edit cells.

Are there any easy solution for my problem, or are there any other thread about this that I have missed?

$("#tabs").tabs( {
    "show": function(event, ui) {
        var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
        if ( oTable.length > 0 ) {
            oTable.fnAdjustColumnSizing();
        }
    }
});

// Sets datatable for main table in offerts(admin).
var oTable = $('.display.offerts').dataTable({
    "bJQueryUI": true,
    "bStateSave": true,
    "aoColumns": [
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        { "bSortable": false }
    ],
    "oLanguage": {
        "sProcessing": "Processing...",
        "sLengthMenu": "Visa _MENU_ rader",
        "sZeroRecords": "Inga matchande rader funna",
        "sEmptyTable": "Ingen data tillgänglig i tabellen",
        "sLoadingRecords": "Laddar...",
        "sInfo": "Visar _START_ till _END_ av _TOTAL_ rader",
        "sInfoEmpty": "Visar 0 till 0 av 0 rader",
        "sInfoFiltered": "(filtrerat från _MAX_ rader)",
        "sInfoPostFix": "",
        "sSearch": "Sök i alla kolumner:"
    }
});

  /* Apply the jEditable handlers to the table */
    $('td.contacted, td.complete, td.sold', oTable.fnGetNodes()).editable( '../index.php/offerts/update_offert_status', {
        data 开发者_StackOverflow中文版   : "{'Ja':'Ja','Nej':'Nej'}",
        type    : 'select',
        submit  : 'OK',
        "callback": function( sValue, y ) {
            var aPos = oTable.fnGetPosition( this );
            oTable.fnUpdate( sValue, aPos[0], aPos[1] );
        },
        "submitdata": function ( value, settings ) {
            return {
                "row_id": this.parentNode.getAttribute('id'),
                "column": oTable.fnGetPosition( this )[2]
            };
        },
        "height": "14px"
    });

Thanks in advance!


I think (but i'm guessing since there is no html code) that your problem is that you are initializing more than one datatable here:

  var oTable = $('.display.offerts').dataTable

And than when you get the nodes from the object you get the nodes of one table only.

  $('td.contacted, td.complete, td.sold', oTable.fnGetNodes())

If you have more than one table you should use ids and not classes so that you can have different objects on which you can work

0

精彩评论

暂无评论...
验证码 换一张
取 消