Data Rendering - Query The Database

Data Rendering - Query The Database

dlynchdlynch Posts: 10Questions: 4Answers: 1
edited December 2015 in Free community support

Hello everyone,

I have come to the conclusion I need to manipulate my data through the render, however I am not sure where or how to go about it. I am looking for a bit of direction because I cant seem to find a manual of any sorts. Java is not my strong point.

I have data coming through Server Side Processing as this:

{
    "draw": 0,
    "recordsTotal": 2,
    "recordsFiltered": 2,
    "data": [
        ["ATS20151209_78983", "2|6|8|4", "1", "12-09-15", "CM20151020_999999999", "Curabitur egestas nunc nisl, sit amet feugiat erat tincidunt eu. Praesent consequat blandit venenatis. Pellentesque habitant mor"],
        ["ATS20151209_78984", "2|8", "3", "12-09-15", "CM20151020_999999998", ""]
    ]
}

There are two pieces of data I want to change before they are displayed. The first is an array of unknown size (In the above example give as 2|6|8|4 & 2|8). I want to query a table in my database that has the corresponds to the text values. Same thing with the second value except this time there is no array shown as 1 & 3 above.

I am not looking for anyone to write the code but a little direction is nice since the documentation is covering so much. I don't even know what I should be calling this or looking up.

Thank you.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin
    edited December 2015

    I want to query a table in my database that has the corresponds to the text values.

    As in you want to display a label that is identified by the integer value (a name for example)? Or you want to display the integer? I'm going to assume the former.

    There are two options:

    1. Pre-load all of the names and lookup the values in a columns.render function.
    2. Use the same approach that I have done in Editor and load both the index data (assuming you even need it), and the labels. Then you can use the labels for the display and the indexes for editing (again, assuming you even need them). This will require you to change the JSON format returned from the server - the Editor example uses objects as I think that is easier to work with for such a use case.

    I would suggest that 2 is easier - assuming you can change the data returned from the server.

    There are other options as well - if you don't need the indexes, then just replace them with the data that is needed for example.

    Allan

  • dlynchdlynch Posts: 10Questions: 4Answers: 1

    Option 2 sounds like what I want I am not sure though because the link you placed gives a 404.

  • dlynchdlynch Posts: 10Questions: 4Answers: 1
    edited December 2015
    mysql Table One
    -----------------
    employeeID   | employeeName
    1            | Johnny
    2            | David
    
    mysql Table Two
    --------------------
    workItemID   | employeeOwners
    5011         | 1
    5012         | 1,2
    
    -----------------------------------------
    

    The datatable should basically display Table Two but instead of showing employeeOwners as a number or array of numbers it should pull use the first table and get employeeName where employeeID = employeeOwners (Keeping in mind it could be an array but that parts simple).

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin

    the link you placed gives a 404.

    Sorry - there should have been an l at the end of the URL. I've corrected it now.

    Allan

  • dlynchdlynch Posts: 10Questions: 4Answers: 1

    Is the purchase of the Editor needed to preform this join action? I do not need the functionality of editing from the front end (that is the purpose of forms).

    Or do I just need to download some more files and change the file producing the JSON? Your documentation is great but only for those who understand it.

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin
    Answer ✓

    Is the purchase of the Editor needed to preform this join action?

    No. You can modify the server-side processing demo script to add join abilities or create your own server-side processing script that will suit your needs. The client / server protocol is documented in the manual.

    I linked to the Editor example primarily just to show you the structure that I have used to solve this problem, not to try and sell Editor (in this case ;-) ).

    Allan

This discussion has been closed.