Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
How to apply conditional checking on input columns in a JavaScript Datatable

Below shows one of a column in my javaScript Datatable:

       {
            "className": 'child_grid',
            "data": function (data) {
                return '<input disabled id="comment" data - val="true" type = "text" value = "' + data.LookupComment + ' != null ? ' + data.LookupComment + ' : """ style = "height: 2rem !important;" >';
            }                    
        },

Here I have check for null value in the input field. If it is null, want to show blank. For that I have applied condition in the value="" property. But instead of checking condition, it is printing whole conditions in the UI.

If I directly use the value variable in the input value property, it displays null in case of null value as given below.

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What about creating the value prior to the return?
Something like this..

"data": function(data) {
  const value = data.LookupComment !== null ? data.LookupComment : '';
  return '<input disabled id="comment" data-val="true" type="text" value="value" style = "height: 2rem !important;" >'; 
}                            
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!