ypnos-web / cakephp-datatables

CakePHP3 Plugin for DataTables plug-in for jQuery
MIT License
27 stars 24 forks source link

render 'Contain' with null #58

Open jevchan91 opened 6 years ago

jevchan91 commented 6 years ago

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

ypnos-web commented 6 years ago

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

challgren commented 6 years ago

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

ypnos-web commented 6 years ago

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.

challgren commented 6 years ago

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.