I have an issue with trying to combining two columns into an ajax table
I have an issue with trying to combining two columns into an ajax table
![forte](https://secure.gravatar.com/avatar/d16d5bd809732ec7b843cc5dc821a0ec/?default=https%3A%2F%2Fvanillicon.com%2Fd16d5bd809732ec7b843cc5dc821a0ec_200.png&rating=g&size=120)
What I would like is to merge the First_Name and Last_Name columns together. The code provided almost does it, but return is the first name and the second letter of the first name. I know it's because '+ data[1]+'...
I'm not sure how to call the Last_name object, I could use some help .
$(document).ready(function(){
var URL = 'here is were I put the URL to the server'
var table;
table = $('#example').DataTable( {
processing: false,
severSide: false,
ajax: {
url: URL,
type: "GET",
crossDomain: true,
dataType: "jsonp",
dataSrc: 'Seller_Leads_Information'
},
columns : [
{data: 'First_Name'},
{data: 'Last_Name'},
{data: 'Emailid'},
{data: 'Phone'},
{data: 'Street'},
{data: 'City'}
],
columnDefs: [{
"targets": 0,
"render": function ( data, type, row ) {
return data +' '+ data[1]+' ' ;
},
"targets": 0
},
{"visible": false, "targets": [ 1 ]}
]
} );
});
Replies
Since you are using objects you will want something like this:
return data +' '+ row.Last_Name +' ' ;
And you can remove the Last_Name column from the table and
columns.data
if you like. You can still access it as part of the Datatables data.Kevin
that work thanks.....
One more question, could I use other render call inside the columnDefs: [ ] to return the address.
var table;
table = $('#example').DataTable( {
processing: false,
severSide: false,
ajax: {
url: URL,
type: "GET",
crossDomain: true,
dataType: "jsonp",
dataSrc: 'Seller_Leads_Information'
},
]
What you have should work. But it looks like you are hiding that column with this:
Is it not working for you?
Kevin
Sorry, I should have giving you the full code ... I'm getting a syntax error, could you take an other look for me ... thx
var table;
table = $('#example').DataTable( {
processing: false,
severSide: false,
ajax: {
url: URL,
type: "GET",
crossDomain: true,
dataType: "jsonp",
dataSrc: 'Seller_Leads_Information'
},
I work it out.... thx for all the help...
var URL = 'here is were I put the URL to the server'
var table;
table = $('#example').DataTable( {
processing: false,
severSide: false,
ajax: {
url: URL,
type: "GET",
crossDomain: true,
dataType: "jsonp",
dataSrc: 'Seller_Leads_Information'
},