0

我可以成功地将数据加载到表中。但我需要将此数据加载到 Jqgrid 中。这所有数据都来自动态数组(包括表头)。我尝试了它,但我仍然无法做到这一点。任何人都可以帮忙吗?

我使用了 Jqgrid 4.0

这是我的数据加载到表的代码 ///////////////////////////////

<table id="jqTable" border="1" style="margin-top: 10px;">
    <thead>
        <tr>
            <th style="min-width: 50px;"></th>
            {% for keys,values in tableHead %}

                <th style="min-width: 50px;"><a href="#" onclick="loadResourceSummary({{projectIds[values['unit_code']]}},null,null)">{{values['unit_code']}}</a></th>

            {% endfor %}
            <th style="min-width: 60px;">{{'Total'}}</th>
        </tr>
    </thead>

    {% for keys,values in matrix %}
        <tr>
            <td><a href="#" onclick="viewSummary({{userIds[keys]}})">{{full_names[keys]}}</a></td>
            {% for key,value in values %}
                {% if value=="-"%}
                    <td style="text-align: right;">{{value}}</td>
                {% else%}
                    <td style="text-align: right;"><a href="#" onclick="loadRRFSummary({{projectIds[key]}},{{userIds[keys]}});"> {{value ~" %"}} </a></td>
                {%endif%}
            {% endfor %}
            <td bgcolor="#dcdcdc" style="text-align: right; font-weight: bold;">{{(totalAllocationOfTheUser[keys]) ~" %"}}</td>
        </tr>
    {% endfor %}
    <tr>
        <td><strong>{{'Total'}}</strong></td>
        {% for keys,values in totalAllocationOfTheProject %}
            <td bgcolor="#dcdcdc" style="text-align: right; font-weight: bold;">
                {{values}}

            </td>
        {% endfor %}
        <td style="text-align: right; font-weight: bold;"><span style="color: #a52a2a;">{{grandTotal}}</span></td>
    </tr>
</table>

/////////////////////////////这是树枝文件的返回数组 /////// ///////////////////////

$tableHead=$userDAO->getSelectedProjectsForMatrix($selectedProjects);
        return $this->render('AdminBundle:User:ProjectsMatrix.html.twig', array(
            'matrix'=>$matrix['matrix'], 'tableHead'=>$tableHead,'full_names'=>$matrix['userWithFullName'],
            'totalAllocationOfTheUser'=> $matrix['totalAllocationOfTheUser'],'totalAllocationOfTheProject'=>$matrix['totalAllocationOfTheProject'],
            'form' => $form->createView(),'date'=>$date,'userIds'=>$matrix['userIds'],'projectIds'=>$matrix['projectIds'],'grandTotal'=>$matrix['grandTotal']
        ));
4

0 回答 0