douzhui1972 2014-07-25 12:20
浏览 45
已采纳

在JQGrid列摘要中使用CakePHP从JSON编码响应访问密钥

I am sending json encoded results from my controller to my view and displaying data in jqgrid. The data is displaying fine. However, I added two integers to the response I am returning and I want to display them in the grid in one of the column's summary. This is what it looks like in the controller:

    $response->TotalNum = $total_items;
    $response->PercentNum = $percent_items;
    return json_encode($response);

How do I access those values in my grid? I would like to append them to the summary. Sort of like this, though I know this won't work:

{name:'itemcounts',index:'itemcounts', width: 50, sorttype:'int',summaryType:'sum', summaryTpl: 'Total<br>Count: {0}<br>Total Items: **$response['TotalNum']** (**$response['PercentNum']**%)', formatter:'number',formatoptions:{decimalPlaces: 0}},

Thank you!

  • 写回答

1条回答 默认 最新

  • duanchanguo7603 2014-07-25 15:33
    关注

    The easiest way to display summary row and fill it with the data prepared on the server is the usage of additional userdata property in the server response (its values mast be an object with properties defined as the column names) and options footerrow: true and userDataOnFooter. The old answer provides the corresponding example. If you prefer calculate the values for the footer row on the client side (which can be slowly) then you can calculate the summary using getCol and then call footerData explicitly inside of loadComplete callback. By the way the setting summaryType:'sum' will be used in case of groping of data (see here for example).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?