jqGrid刷新本地数据(JSON对象) [英] jqGrid Refreshing Local Data (JSON Object)

查看:340
本文介绍了jqGrid刷新本地数据(JSON对象)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将jqGrid与本地数据一起使用,并且发现了两个问题:

I'm trying to use jqGrid with local data and I'm finding a couple of issues:

我正在像这样初始化事情:

I'm initializing the thing like so:

function refreshGrid($grid, results)
{
    $grid.jqGrid({
  data: results,
        datatype: "local",
        colNames:['#','File', 'Category', 'Line Number', 'Message Text','Detailed'],
        colModel:[
            {name:'count',index:'count', width:100, resizable: true},
            {name:'basename',index:'basename', width:100, resizable: true, classes:['basename']},
            {name:'category',index:'category', width:60, resizable: true},
            {name:'linenumber',index:'linenumber', width:60, resizable: true},
            {name:'text',index:'text',width:400, resizable: true},
            {name:'detailed',index:'detailed',width:100,classes:['detailed'], resizable: true }
            ],
        viewrecords: true,
     rowNum:100,
     rowList:[100,200],
     pager: '#debug_errors_pager',
     caption:"JSON Example"
 });
}

我传入的数据results是对象数组.

The data I'm passing in, results is an array of objects.

问题:

1)寻呼机完全关闭.它显示了正确的计数,但实际上并没有让我翻阅数据.

1) The pager is totally off. It shows the correct count, but it doesn't actually let me page through the data.

2)我无法刷新数据.我正在使用自己的搜索功能找到我的results.我不知道如何更新现有数据.网格第一次初始化.在随后的尝试中,它将初始化为一个空表.

2) I can't refresh the data. I'm using my own search function to arrive at my results. I can't figure out how to update the existing data. The grid initializes the first time. On subsequent attempts, it initializes to an empty table.

3)我尝试过类似的事情:

3) I've tried things like:

$grid.empty()-无效,因为$ grid对象由jqgrid装饰.我正在尝试核对"旧网格,并只是将其重新呈现为一种解决方法. `$ grid.trigger('reloadGrid')-不起作用,不知道为什么.

$grid.empty() - Doesn't work because the $grid object is decorated by jqgrid. I'm trying to "nuke" the old grid and simply re-render it as a workaround. `$grid.trigger('reloadGrid') - Doesn't work, don't know why.

注意:这是使用jQGrid 3.7.

Note: this is using jQGrid 3.7.

推荐答案

您可以使用简单的方法:

You can use simple:

jQuery("#list")
    .jqGrid('setGridParam',
        { 
            datatype: 'local',
            data:mydata
        })
    .trigger("reloadGrid");

这篇关于jqGrid刷新本地数据(JSON对象)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆