Combine render "[, ].name" & render: editIcon together?
Combine render "[, ].name" & render: editIcon together?
How do I use render "[, ].name" as well as the render: editIcon together?
I've got everything working with my mjoin and pulling in the names seperated however I want to be able to edit it inline like the example Edit Icon. I've got it working on my other fields but not having any luck with the comma seperated.
Hope that makes since
This question has an accepted answers - jump to answer
Answers
Are you able to link to your page so we can take a look, please. Or if not, please can you post your table initialisation code and a snippet of the data you want rendered.
Colin
var table = $('#trac').DataTable( {
responsive: true,
dom: 'Bfrtip',
ajax: {
url: 'trac.php',
type: 'POST'
},
serverSide: true,
order: [[ 1, 'asc' ]],
columns: [
{ // Responsive control column
data: null,
defaultContent: '',
className: 'control',
orderable: false
},
{ data: "trac_title", render: editIcon },
{ data: "types.type_name", render: editIcon },
{ data: "vendors.company", render: editIcon },
{ data: "users", render: "[, ].users_name"},
{ data: "server", render: editIcon },
{ data: "system_name", render: editIcon },
{ data: "start_date", render: editIcon },
{ data: "end_date", render: editIcon }
],
select: true,
buttons: [
{ extend: "create", editor: editor },
{ extend: "edit", editor: editor },
{ extend: "remove", editor: editor }
]
} );
The Contact Users Column I can't get it to have the names comma separated as well as the edit inline icon.
Can you also post a couple of lines of the data as it's returned by the server, please,
Colin
Like so?
trac: {trac_title: "Testing", server: "this one",
start_date: "2021-11-04",
end_date: "2021-11-04",…}
trac_systems: {system_name: "Test System2"}
trac_types: {type_name: "Certificate"}
trac_users: [{user_id: "1234567", users_name: "Chris Brown"},…]
0: {user_id: "1234567", users_name: "Chris Brown"}
1: {user_id: "9876543", users_name: "Colt Williams"}
trac_vendors: {company: "Vendor Name"}
I reformatted it here, but it looks like there are a few errors such as missing commas between the elements. Could you just verify that they are present in the posted data - this was truncated, as you can tell by the ellipses in your post.
Sorry I didn't notice that when I pasted it in after cleaning it up it appears that what I have matches your post
You don't I'm afraid - you can have only one render function. You would need to create a function to do that. However for this specific case, you could use:
The
columns.data
property can use the array syntax as well.Allan
Perfect, I knew it had to be something simple.
Thanks Allan!