AutoFill - Losing Functionality

AutoFill - Losing Functionality

traslerktraslerk Posts: 9Questions: 3Answers: 0

Hi, I've just started with the DataTables and is proving an excellention solution for my application - so thank you!

I've just added the AutoFill to 10.8. When my page first loads it works.

I have functionality to add an input and then update the cell (and datatable data) on the click of certain <td>'s

This is on the on click of certain cells

$(document).on('click', '#myTable td.myCell', function (e) {
        openInput($(this));
    });

Here is the code..

function openInput(cell) {
    var value = cell.text();
    cell.empty();
    $("<input>")
        .attr('type', 'text')
        .val(value)
        .blur(function (e) {
            closeInput(cell);
        })
        .appendTo(cell)
        .focus();
}

The closeInput function validates the input and then removes the input by calling this function

// update the cell value and and the dataTable cell (the update cell can be done on cells without an input so needs is(":input"))
function updateCell(cell, value) {
    value = value.toUpperCase();
    if (cell.is(":input")) {
        cell = cell.parent();
    }
    cell.empty().text(value);
    table.cell(cell).data(value);
}

All this works fine, but I lose the functionality of the AutoFill.

How do I either prevent the datatables from losing functionality of AutoFill or add the functionality on again?

Replies

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    Could you link to the page showing the issue please? I must confess I don't immediately know what the issue is there. That looks like it should work.

    You shouldn't need cell.empty().text(value); - you could drop that. DataTables will do it for you.

    Allan

  • traslerktraslerk Posts: 9Questions: 3Answers: 0

    Hi Allan

    Sorry, I've only just seen this as been away on holiday and thought i'd get an email confirmation about a reply so apologies for not checking sooner.

    I can't send you a link to the site as it's on a work server.

    I've still not managed to get this working and no idea why, it works fine until I click a <td> which creates and removes an input.

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    Are you able to reproduce the error on JSFiddle or http://live.datatables.net ?

    Allan

  • traslerktraslerk Posts: 9Questions: 3Answers: 0

    I'll have a go at it and get back to you,

This discussion has been closed.