[英]jqGrid: reload data from json-string
I know, that there is several similar questions are exists on SO, but despite it I creating this question because: 我知道,SO上存在几个类似的问题,但是尽管如此,我还是创建了这个问题,因为:
- I still don't get it :) -我还是不明白:)
- I want to create a topic that possibly will cover a problem more complete. -我想创建一个可能涵盖更完整问题的主题。
I reconstructed my production setup in simplified way, it available by link below. 我以简化的方式重建了生产设置,可以通过下面的链接获得它。 In short - I have simple jqGrid, that uses
jsonstring
as dataType
, and datastr
with JSON data. 简而言之-我有一个简单的jqGrid,它使用
jsonstring
作为dataType
,并使用JSON数据的datastr
。 And then by firing this: 然后通过触发:
$("#grid").setGridParam({'datastr': myNewData}).trigger('reloadGrid');
Im trying to reload data in grid, but it just doesnt work. 我试图重新加载网格中的数据,但它不起作用。 What am I missing?
我想念什么?
ps ps
Also it is matter for me, that grid has summary row which defined with userdata
. 对我来说也很重要,该网格具有用
userdata
定义的摘要行。
It's very seldom that you really need to use datatype
which values other as "local"
, "json"
, "jsonp"
or "xml"
. 这是非常难得,你真的需要使用
datatype
,其值作为其他"local"
, "json"
, "jsonp"
或"xml"
。 Most usage of other datatype
can be easy replace to the tree main datatypes. 其他
datatype
大多数用法可以很容易地替换为树主数据类型。 If you use "jsonstring"
, "xmlstring"
or "clientSide"
then the datatype
will be changed to "local"
after loading of data (see the line of source code for example). 如果使用
"jsonstring"
, "xmlstring"
或"clientSide"
则在加载数据后,数据datatype
将更改为"local"
(例如,参见源代码行 )。 So if you really need to use datatype: "jsonstring"
you can fix reloading by usage 因此,如果您确实需要使用
datatype: "jsonstring"
,则可以按使用情况修复重新加载
$("#grid").setGridParam({
datastr: myNewData,
datatype: "jsonstring" // !!! reset datatype
}).trigger("reloadGrid");
Additionally I could see that you used pager: false
option of jqGrid. 另外,我可以看到您使用了jqGrid的
pager: false
选项。 It's wrong option. 这是错误的选择。 If you don't need to use local paging of data I recommend you
如果您不需要使用本地数据分页,建议您
pager
option. pager
选项。 Default value pager: ""
is already OK. pager: ""
已经可以。 rowNum
parameter with some large enough value like rowNum: 10000
. rowNum
参数,例如rowNum: 10000
。 Default value of rowNum
is 20. So if you don't want to display only the first 20 rows of the input data you should increase the value of rowNum
. rowNum
默认值为20。因此,如果您不想仅显示输入数据的前20行,则应增加rowNum
的值。 The last recommendation: you should include sorttype: "integer"
(see the documentation ) to columns which holds integer values. 最后一条建议:您应该在包含整数值的列中包括
sorttype: "integer"
(请参阅文档 )。 It will fix sorting of data if the user clicks on the column header. 如果用户单击列标题,它将修复数据排序。 You should consider to use column templates too (see the old answer ).
您也应该考虑使用列模板(请参阅旧答案 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.