【问题标题】:Omines DataTables does not load data to table on Symfony 4Omines DataTables 不会将数据加载到 Symfony 4 上的表中
【发布时间】:2019-02-13 23:06:34
【问题描述】:

我在将数据加载到我的表时遇到问题。我尝试使用文档https://omines.github.io/datatables-bundle/ 中的示例中的 ArrayAdapter,但它也不会加载数据。我只有专栏的标题。阿比想法?所有 ajax 请求都可以。

这里是行动:

public function listCalls(Request $request)
{
    $table = $this->createDataTable()
        ->add('id', TextColumn::class, [
            'label' => 'id'
        ])
        ->createAdapter(ORMAdapter::class, [
            'entity' => Call::class,
            'query' => function (QueryBuilder $builder) {
                $builder
                    ->select('c')
                    ->from(Call::class, 'c')
                ;
            },
        ])
        ->handleRequest($request);

    if ($table->isCallback()) {
        return $table->getResponse();
    }

    return $this->render('shop/calls_list.html.twig', [
        'datatable' => $table
    ]);
}

这里是视图:

{% extends "shop/base.html.twig" %}

{% block title %}List{% endblock %}

{% block content %}
    <div id="presidents">Loading...</div>
{% endblock %}
{% block scripts %}
    <script src="{{ asset('bundles/datatables/js/datatables.js') }}"></script>
    <script>
        $(function() {
            $('#presidents').initDataTables({{ datatable_settings(datatable) }});
        });
    </script>
{% endblock %}

【问题讨论】:

    标签: jquery symfony datatables


    【解决方案1】:

    我找到了解决方案。 JavaScript 加载顺序错误。

    【讨论】:

    • 为了更清楚,您应该在答案中至少添加正确的 javascript 加载顺序。
    猜你喜欢
    • 2019-09-18
    • 2021-07-27
    • 2019-12-31
    • 1970-01-01
    • 2019-06-26
    • 2013-07-07
    • 2014-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多