Moti Mashiah
asked on
javascript
Hi Guys,
I have this code:
What I'm trying to do is return dynamic value into input. Please look at the code above and this row example:- '<td>' + '<input type="text" value="d.Price"/>' + '</td>' +
I have this code:
function format(d) {
// `d` is the original data object for the row
return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' +
'<tr>' +
'<td>Price:</td>' +
'<td>' + '<input type="text" value="d.Price"/>' + '</td>' +
'</tr>' +
'<tr>' +
'<td>Cost:</td>' +
'<td>' + d.Cost + '</td>' +
'</tr>' +
'<tr>' +
'<td>Extra info:</td>' +
'<td>And any further details here (images etc)...</td>' +
'</tr>' +
'</table>';
}
What I'm trying to do is return dynamic value into input. Please look at the code above and this row example:- '<td>' + '<input type="text" value="d.Price"/>' + '</td>' +
ASKER
Hi ,
Thank you for your answer.
I'm using dataTable and this code taken from there.
Please see this link and let me what do you think I should do:
https://datatables.net/examples/api/row_details.html
Thank you for your answer.
I'm using dataTable and this code taken from there.
Please see this link and let me what do you think I should do:
https://datatables.net/examples/api/row_details.html
Change
So it would be:
from this: "d.Price"
to this: "' + d.Price + '"
So it would be:
'<input type="text" value="' + d.Price + '"/>'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
solved my issue.
---
As a side note, chaining strings like this is a very bad practice due to performance issues.
I understand that it makes it easier to read, but it's far from ideal.
If this is the only piece of code you have that does this and you don't call it a lot of times (like in a loop), it's ok, otherwise you should consider better options.