Enable input text datatable

Enable input text datatable

cgretaquispecgretaquispe Posts: 9Questions: 1Answers: 0

Estimates
I need an URGENT help I have my table, which I added input by mRender text this disabled by default, but when I add a row to the table, which is being added after the paging, this is not disabled, almost any change I want to make a text input that is in another paging (eg disable a text input that is located in the paging 2), this is not disabled:

When I finish adding rows to datatable for JSON, placed a function Add New, which adds a row to the last, but this is not disabled even though he indicated that deshbilite.

function fn_Agregar_NuevaCuenta() {
$('#tbaPlanCuenta').dataTable().fnAddData(['', '', '', '0', '', '', '', '', '', '', '']);

        var oTable = $('#tbaPlanCuenta').dataTable();
        var posicion = oTable.fnGetData().length - 1;

        //This does not work, not disabled if the input text are in another page.
        $("#itx_2_" + posicion).attr("disabled", false);
        $("#itx_3_" + posicion).attr("disabled", false);
        $("#itx_6_" + posicion).attr("disabled", false);
        $("#chk_7_" + posicion).attr("disabled", false);
        $("#ism_9_" + posicion).attr("disabled", true);
        $("#ism_10_" + posicion).attr("disabled", true);
        //******************************************

        var sPosicion = parseInt(sValidacion[3]) + 1;
        var sCaracteres = "?c9m999999999999999999999999999";
        var sSalida = sCaracteres.substr(0, sPosicion) + "-" + sCaracteres.substr(sPosicion);
        $("input[name='nCuenta']").mask(sSalida, { placeholder: "" });
    }

regards

This question has an accepted answers - jump to answer

Answers

  • cgretaquispecgretaquispe Posts: 9Questions: 1Answers: 0
    edited June 2014

    ....

  • DaharkDahark Posts: 28Questions: 1Answers: 0
    edited June 2014

    Hey cgretaquispe,

    the Problem is that you are using pagination. When using pagination then the elements on the second and third and so on pages, are not in the DOM allready. This means, your Selector $('#itx_2_" + posicion) doesn't finde the wanted objects.

    If I'm correct, you need to access the elements through the dataTables object.

    Try something like this:

    oTable.$("#itx_2_" + pocision).attr("disabled", false);
    
  • cgretaquispecgretaquispe Posts: 9Questions: 1Answers: 0
    edited June 2014

    OK THANKS,
    SOLUTIONS

    oTable.$("#itx_2_" + pocision,oTable .getNodes()).attr("disabled", false);

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited June 2014 Answer ✓

    Two more using the new API:

    • table.rows().nodes().to$().find( '#itx_2_' + posicion ).attr("disabled", false);
    • $('#itx_2_' + posicion, table.rows().nodes()).attr("disabled", false);

    Allan

This discussion has been closed.