cakephp-datatables icon indicating copy to clipboard operation
cakephp-datatables copied to clipboard

render 'Contain' with null

Open jevchan91 opened this issue 7 years ago • 4 comments

below this is main query with null return, render with 'number' parameter without problem. number":null,"user":{"username":"test"}

below this is contain query with null, since render parameter is 'user.username', so datatable cant get '.username' and popup an error. number":null,"user":{"user":null}

any solutions? thanks

jevchan91 avatar Jun 11 '18 14:06 jevchan91

I think the only solution to this problem is to use a custom render callback which can then ignore null objects.

ypnos-web avatar Jun 11 '18 17:06 ypnos-web

I agree it has been a very annoying. But the only solution I know is to use a customer render.

challgren avatar Aug 25 '18 08:08 challgren

Right now we use $.fn.dataTable.render.text() as a default render callback as it sanitizes the content (like h() method).

I wonder if we should use a default render callback that also ignores NULL. So far I found it might be better to not silently fail by default. But I wonder if we should have a 'defaultRenderCallback' kind of config for the helper.

ypnos-web avatar Aug 25 '18 16:08 ypnos-web

I honestly think just using a custom rendered is fine. Im my use cases mainly I'm generating a link to a belongsTo relationship anyways so during the link generation I'm checking for null.

challgren avatar Aug 25 '18 21:08 challgren