Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read Value of Hidden Column in JQuery

I need to hide a column on the table, but after that I cannot read selected row's hidden column value.

 dtTable = $('#lookupTable').DataTable({
       "columnDefs": [
           {
               "targets": [ 0 ],
               "visible": false,
               "searchable": false               
           }
        ],  

        aaData: data,
        aoColumns: cols,
        paging: false,
        scrollCollapse: true,
        destroy: true

    });

as you see the first column is hidden now. And I am trying to read the column value with that code

    selectedIndex = $(this).find('td:eq(0)').text(); 

if i delete <"visible": false> from the code i can read the first column's value, but if it is hidden it gives me second column value.

I tired to change "witdh" property but it didnt work..

like image 377
unbalanced Avatar asked Oct 12 '15 13:10

unbalanced


People also ask

How to check hidden value in jQuery?

#3 jQuery Code To Get hidden field value by typevar getValue= $("input[type=hidden]"). val(); alert(getValue); Here in the above jquery code, we select input hidden filed by its type i.e hidden, and then by using jquery . val() we get the hidden field value.

What is input type hidden used for?

Definition and Usage. The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.

How can access hidden field in asp net code behind?

Right click on project and select Add-->Add New Item and select Web Form. Add a new Web Form called "Default. aspx". Now, drag and drop the HiddenField Control on the page.


1 Answers

The correct answer is pretty old. So, if the correct answer does not work out for you. Please try this method :

selectedIndex = dtTable.row(this).data();

This code will return the raw json object which was fetched for this row. something like :

{
   "modify":"false",
   "lastModify":"Tuesday",
   "name":"abc",
   "DT_RowId":"row_1",
   "fileID":"0bde976"
}

To get the "fileID" you just need to :

alert("ID = "+selectedIndex.fileID);
like image 85
Mohd Naved Avatar answered Oct 04 '22 04:10

Mohd Naved