How to add to row id to the join value?
How to add to row id to the join value?
ziv@kpmbro.com
Posts: 73Questions: 28Answers: 4
in General
Hello.
In my table i am making a join connection to another table, and i want to show in the table : row_id + join_value.
example: 5 - jon
also
https://editor.datatables.net/examples/simple/join.html -> i want to add the id of the location ("2 - London").
i tried to add getFormatter() to the join command but it didnt work..
Thanks
This discussion has been closed.
Answers
The way I would suggest doing it is have to separate
Field::inst()
fields in your PHP and then use a client-side renderer to combine the two values into a single column in the table.Allan
Hi Allan and thanks for the help.
I tried to do that using the string formatter method and didn't quite worked.
Is it even possible to render via that method because it says that i canot get the row data in this method.
this is how my js data looks like.
every time i add the render i get this error:
DataTables warning: table id=offer_status_at_upload_platforms - Requested unknown parameter 'offers_main_table.title' for row 0, column 1. For more information about this error, please see http://datatables.net/tn/4
basically i want it to show : offer_status_at_upload_platforms.offer_id + offers_main_table.title.
any thoughts about that?
thanks !
Yes, as I say, I would suggest using a client-side render. You need to define a function as detailed in the documentation that will combine the two fields as you need.
The error you are seeing suggests that there is no
offers_main_table.title
property in the JSON data returned from the server.Allan
Allan
Thanks Allan
I cant figure out how to bind those two strings together using the string data only,
this is the json data that coming back from the server.
I tried every combination possible
but still didnt get it..
for example
how can i tell the render to combine those two strings ?
it seems very strange...
Thanks
As I mentioned, you need to use a function:
Allan
Yes but i dont have javascript in my code... ( i wish ),
I configure my table with strings, like it says in here
https://datatables.net/manual/data/renderers
"Strings
A less common option for formatters is as a string to simply point at the data that should be used in the table. This is similar to the way that columns.data is often used, although keep in mind that the renderer will only have access to the data pointed to by columns.data rather than the full row.
Continuing the examples using the JSON data structure from above, consider a column that should show the first name of the creator:"
I'm afraid I don't understand - why can't you use a function? Yes, you can use a string with
columns.render
, but that only allows you to access a single data point from the source data object. If you want to access more than one, or combine them, you have to use a function.Allan