0

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

0

1 Answer 1

1

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;" >'; 
}                            
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.