Server side render
Server side render
Restful Web Services
Posts: 202Questions: 49Answers: 2
in Editor
Is there a method to render on the server side which excludes the data from being sent to the 'Edit' and 'Create' modes? I.e. I want to replace a boolean 1 or 0 choice in my database with a graphical icon.
So 1 become <span class="fa fa-check-square fa green"></span>
and 0 becomes <span class="fa fa-square-o fa"></span>
.
I can do this server side using getFormatter
but then when I load the edit mode the checkbox value is incorrect because the underlying data is wrong.
Thanks
This discussion has been closed.
Answers
Hi @Restful Web Services ,
It sounds like you need to use
columns.render
to modify your booleans into thespan
icons. There's a similar example on that reference page that should be helpful.Cheers,
Colin
Hi Colin.
Thanks for your reply.
I am specifically trying to find a way to do this server side in the PHP layer? Is it possible or does this type of thing have to be done on the client side?
Chris
We were debating whether you really meant server!
You can use the same method, but in reverse, so instead of converting to the
-span tag
, you take that and convert to the boolean.I'd surprised if you can't do something similar with some PHP on the server, my knowledge of that end is lacking, unfortuntately.
C
Going to jump in here . Editor will always work on the raw data that is present in data object for the row. To that end, you would typically have the boolean data transferred from the server to the client and use
columns.render
as Colin mentioned to display it in the rendered form in the DataTable, while having the boolean for Editor.One other advantage is that the JSON data to transfer is smaller, so a slightly faster download!
If you really needed to have the server send the rendered form, you'd need to have it return both the rendered form and the unrendered one, which you can do with an alias - e.g.:
Then instruct DataTables to display
myFieldRendered
and Editor to editmyField
.I would suggest using
columns.render
over that approach though.Allan
Hi Allan,
Thanks for the input. I have adopted your suggestion of splitting the fields.
I have a few
mJoin
functions in place which load a fair amount of data as I am yet to find a suitable way to set an SQL styleLIMIT
on anmJoin
so the small amount of extra data needed for this graphical element is kind of irrelevant.I output the JSON to multiple places so I thought it was better to just have to add the graphical icon once, i.e. at the source, rather than each location the data is sent too?
Chris