render array with two fields
render array with two fields
 montoyam            
            
                Posts: 568Questions: 136Answers: 5
montoyam            
            
                Posts: 568Questions: 136Answers: 5            
            I have an mjoin with a one to many situation. I want to return a comma seperated list of First and Last Name. So, basically I am needing to merge these two:
            ,{
                data: "CaseDefendants",
                render:  {
                    _: '[, ].DefendantFirstName'
                }
            }
and
            {
                data: null,
                title: "Defendants",
                render: function (data, type, row) {
                    return row.DefendantFirstName+ ' ' + row.DefendantLastName;
                }
            },
but i can't figure out the correct syntax.
This question has an accepted answers - jump to answer
This discussion has been closed.
            
Answers
You’d need to write a custom renderer for it:
Allan
thanks. i don't know a lot of javascript/jquery functions. .map did the trick. thanks. at first i was wondering where the comma separator was going to come from when looking at your code, but in reading about .map i see that it is returning an array, which is by nature separated by commas??
Oops - I should have added
.join(', ');there! What is probably happening at the moment is that Javascript will be taking thetoString()of the array return which is basically the values comma separated. I think if you look closely at them, you might find that they don't have spaces at the moment. Adding thejoinwill fix that.Allan