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).

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

报告相同问题?

悬赏问题

  • ¥15 SQL Server下载
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求