Server-side processing, having to SQL query some returned data
Server-side processing, having to SQL query some returned data
Hi,
While using server-side processing my script returns the data in the table and can be searched no problem. There is a status field in my database which is numeric, however the status codes stored in that database link to the status names in another.
Is there anyway once the data is returned, I can then lookup the status names from another database from the returned ID's.
E.g column 2 is status. In the database the table returns the numeric value '2', however that 2 actually means 'Open'.
I hope this makes sense and it would be great if someone could provide some assistance with this issue.
I'm just using the default server side scripting file included on the server-side processing documentation page.
Also, would then you be able to search for the words 'Open' or will you have to use '2' as its querying straight back to the database?
Or would it be easier to build up my own searching script form the sent sever-side variables?
Many thanks,
Connor
Answers
Sounds very much like your other question. If your Editor instance contains a left join to the status text table (the one that contains "Open" for example) and you select that "Open" field in your query and return it to the client it should work.
In some instances when your client side rendering is very different from what is stored in the database you would need to do a transformation of the search string that is passed to the server if you use server side. That can be cumbersome. Hence you should think twice about using server side. In most cases it is simply not required.
Here is an example of a transformed search string to search for dates that are stored in the database as "YYYY-MM-DD" while I have two completely different formats on the client side depending on user language. I also allow to search for short and long dates. In addition I need to transform formatted numbers (e.g. using thousand separators and decimal commas instead of points) into the database number format.
If I didn't use server side here I could save a lot of code as you can see above!
Hi,
I understand! It's loading quite a lot of data that's the only issue so its slowing down the loading, what other method could you reccomend?
If you don't have to use server side, don't use it! If you think your queries are too slow try deferRender first. If that is too slow use server side - and deal with its potential issues when filtering your data.
https://datatables.net/reference/option/deferRender
Thanks, I've given that a try now - but my Ajax file loads all of the customer data at once anyway so that setting makes no difference I don't think!
I suppose I've got to take the difficult server-side processing and deal with the issues...