0

好的,事情就是这样......我有这个 jqGrid,我需要的是汇总显示的数据。这个 jqGrid 的定义如下所示

jQuery("#myGrid").jqGrid
    { 
        url:'/loadGrid.php?q=2', 
        datatype: "xml", 
        colNames:[...], 
        colModel:[...], 
        // some other params.
        footerrow : true, 
        **userDataOnFooter : true,** // it should show footer's custom information.
        altRows : true
    }).navGrid('#pagerGrid',{add:false,edit:false,del:false, search:false}); 

loadGrid.php 具有如下所示的下一个结构

$page = $_GET['page']; // get the requested page 
$limit = $_GET['rows']; // get how many rows we want to have into the grid 
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort 
$sord = $_GET['sord']; // get the direction 

// here goes connextion to database and data collection
...
//

if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) 
{
    header("Content-type: application/xhtml+xml;charset=utf-8"); 
} 
else 
{
    header("Content-type: text/xml;charset=utf-8");
}

$et = ">";
echo "<?xml version='1.0' encoding='utf-8'?$et\n";
echo "<rows>";
echo "<page>$current</page>";
echo "<total>$total</total>";
echo "<records>$records</records>";

// and data population
foreach( $data as $key => $value ) 
{ 
    $ff = $value['field_1'];
    echo "<row id='". $ff."'>";
    // $ff = $value['field_1'];
    echo "<cell> <![CDATA[" . $ff . "]]></cell>";
    $ff = $value['field_2'];
    echo "<cell> <![CDATA[" . $ff . "]]></cell>";
    $ff = $value['field_3'];
    echo "<cell> <![CDATA[" . $ff . "]]></cell>";
    // ... and so on whith all column definitions.
    echo "</row>";
}

echo "</rows>";

这可行,但是当显示网格时问题就出现了。在网格的页脚中,我只看到一个空行。如果我放置一些汇总数据并尝试发送到页面,它不会显示任何内容。所以,我需要知道的是我应该如何传递用户数据以供页面读取。

我已经从 jqGrid whiki 中读取了信息,并说了类似 “userData:这个数组包含来自请求的自定义信息。可以随时使用”。但我不知道如何将此信息传递给#myGrid。有人对此有任何想法吗?任何帮助将不胜感激。

4

1 回答 1

1

XML 中的用户数据格式乍一看可能有点奇怪,但这里清楚地记录。您应该在表单中添加一些 XML 元素

...
<page>1</page>
<userdata name="gridColumName1">value1 in the summary</userdata>
<userdata name="gridColumName2">value2 in the summary</userdata>
...

您应该使用与您namecolModel.

于 2011-11-27T00:21:26.593 回答