Database Editor Issue

Database Editor Issue

aleksosaleksos Posts: 6Questions: 0Answers: 0
edited May 2012 in General
Hi all, I have some issues with a table.

I'm allowing users to get data from mysql database, I have inline action link EDIT and DELETE like the example and all it's working fine,
now I'm adding a new link to redirect user to a specific php page for that raw, so I have add editor_go

$('#mytab').on('click', 'a.editor_go', function (e) {

e.preventDefault();
var nRow=$(this).parents('tr')[0];
var aData = oTable.fnGetData(nRow);
alert(aData[2]); <- this aData[N] told me "undefined"
here I have to redirect user to a new page "advanced_editor.php?cid="+cid <- value from the hidden CID field from the database
but I'm not able to access that value of that specific td
} );

this is rest of my code


oTable = $('#mytab').dataTable( {
"bProcessing": true,
"bPaginate": true,
"bInfo": true,
"bLengthChange": true,
"sPaginationType": "full_numbers",
"sDom": "Tfrtip",
"sAjaxSource": "db_adm.php",
"aoColumns": [
{ "mDataProp": "cname" },
{ "mDataProp": "cdescription" },
{ "mDataProp": "ISO2", "bSearchable": false },
{ "mDataProp": "begindate", "sClass": "center", "bSearchable": false },
{ "mDataProp": "enddate", "sClass": "center", "bSearchable": false },
{ "mDataProp": "cid", "bSearchable": false ,"bVisible": false},
{ "mDataProp": null,
"sClass": "center",
"bSearchable": false ,
"bSortable": false,
"sDefaultContent": '
   
' }
]
} );
} );



Thanks a lot Alex

Replies

  • aleksosaleksos Posts: 6Questions: 0Answers: 0
    Solved!


    "aoColumns": [
    { "mDataProp": "cname" },
    { "mDataProp": "cdescription" },
    { "mDataProp": "ISO2", "bSearchable": false },
    { "mDataProp": "begindate", "sClass": "center", "bSearchable": false }, { "mDataProp": "enddate", "sClass": "center", "bSearchable": false }, { "mDataProp": "cid", "bSearchable": false ,"bVisible": false},
    {
    "mDataProp": "cid",
    "sClass": "center",
    "bSearchable": false ,
    "bSortable": false,"fnRender": function ( o, val ) {
    return '        ' } }
    ]
    } );
    } );



    function opensit(val) {
    window.open ('YourNewPage.php?cid='+val,'_self',false)
    return false;
    }


    Thx anyway.
  • aleksosaleksos Posts: 6Questions: 0Answers: 0
    not really solved....
    maybe the two mDataProp : "cid" introduce something wrong because on edit I got
    An SQL error occurred: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'
  • allanallan Posts: 63,546Questions: 1Answers: 10,476 Site admin
    I suspect with that setup that Editor is submitting the primary key as a regular variable - which isn't expected. Can you link me to your page please so I can take a look to see what is happening?

    Allan
  • aleksosaleksos Posts: 6Questions: 0Answers: 0
    Hi Allan thank you for you answer I solved that putting set = false into the dtfield,
    but my main issue is this :

    $('#mytab').on('click', 'a.editor_go', function (e) {

    e.preventDefault();
    var nRow=$(this).parents('tr')[0];
    var aData = oTable.fnGetData(nRow);
    alert(aData[2]); <- this aData[N] told me "undefined"
    here I have to redirect user to a new page "advanced_editor.php?cid="+cid <- value from the hidden CID field from the database
    but I'm not able to access that value of that specific td
    } );
  • allanallan Posts: 63,546Questions: 1Answers: 10,476 Site admin
    What does console.dir( aData ); show you there?

    Allan
  • aleksosaleksos Posts: 6Questions: 0Answers: 0
    Object
    DT_RowId: "row_35"
    ISO2: "it"
    begindate: "01-05-2012"
    cdescription: "man"
    cid: "35"
    cname: "mandingo"
    enddate: "23-05-2012"
    owner: "24"
  • aleksosaleksos Posts: 6Questions: 0Answers: 0
    Thank you for your precious support, have find the solution.

    best regards Alex
This discussion has been closed.