Symfony DataTables return database in ajax.text format

I’m using DataTables in my symfony project to render a table with database info like this:

 <tbody>

                        {% for file in files %}
                            <tr>

                                <td>{{ file.name }}</td>
                                <td>{{ file.primaryCat }}</td>
                                <td>{{ file.secondaryCat }}</td>
                                <td>{{ file.postedAt}}</td>
                                <td>{{ file.tags }}</td>
                                <td>{{ file.location }}</td>
                                <td>{{ file.language }}</td>
                                <td>
                                    {% if app.user.username == file.author %}
                                        <div class="dropdown mb-4">
                                            <button class="btn btn-warning " type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                Edit
                                            </button>
                                            <div class="dropdown-menu animated--fade-in" aria-labelledby="dropdownMenuButton">
                                                <a class="dropdown-item" href="#">Action</a>
                                                <a class="dropdown-item" href="#">Another action</a>
                                                <a class="dropdown-item" href="#">Something else here</a>
                                            </div>
                                        </div>
                                    {% endif %}
                                    <a class="btn btn-info" href="/uploads/{{ file.path }}" target="_blank">View</a>
                                    <a class="btn btn-primary" href="/uploads/{{ file.path }}" download="">Download</a>


                                </td>

                            </tr>
                        {% endfor %}

                        </tbody>
                    </table>

Everything works well but I’d like to implement this exemple :
https://datatables.net/examples/api/row_details.html

Now I don’t know much about ajax, is there a way to go around without ajax or how should I get my data from the database into a file like : objects.txt shown in the exemple

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *