Forum


10:05

10/11/2008

Problem with import with JSON
I have the following code
in JS file.
// import
$("#grid_table").jqGridImport({impurl:"translation_cfg.json",imptype:"json"});
// export
jQuery('#gridconf').click( function() {
var strxml=jQuery('#grid_table').jqGridExport(
{exptype:"jsonstring"});
jQuery('#txmlarea').text(strxml);
})
translation_cfg.json:
{
"url" : "translation_JSON.php?nd=1236783268906",
"height" : "100%",
"page" : "1",
......
}
I am not able to import config from JSON file(previusly exported). When I click to import only refresh is done and empty rectangle appears.
I've tested XML version and works fine. Only issue with XML was that I had to add header and two wraping tags like this.
<?xml version="1.0" encoding="UTF-8"?>
<roots>
<grid>
Exported XML started directly with
<url>translation_JSON.php?nd=1236733458890</url>
<height>100%</height>
<page>1</page>
<rowNum>100</rowNum>
......
Any ideas?
Greetings
Majkel
11:24

Moderators
30/10/2007

Hello,
How is your pager defined in the grid? Do you have read the IMPORTANT NOTES when using these functions?
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
16:40

10/11/2008

"pager" : "#pager2",
Whole JSON
{
"url" : "translation_JSON.php?nd=1236783268906",
"height" : "100%",
"page" : "1",
"rowNum" : 100,
"records" : "38",
"pager" : "#pager2",
"pgbuttons" : true,
"pginput" : true,
"colModel" : [{
"name" : "cb",
"width" : 27,
"sortable" : false,
"resizable" : false,
"hidedlg" : true,
"search" : false
}, {
"name" : "id_item",
"index" : "id_lang_tag",
"width" : 30,
"resizable" : true,
"search" : true
}, {
"name" : "name",
"index" : "name",
"width" : 130,
"resizable" : true,
"search" : true
}, {
"name" : "type",
"index" : "type",
"editable" : true,
"width" : 50,
"resizable" : true,
"search" : true
}, {
"name" : "trans1",
"index" : "trans1",
"editable" : true,
"edittype" : "textarea",
"width" : 200,
"editoptions" : {
"rows" : "5"
},
"resizable" : true,
"search" : true
}, {
"name" : "status1",
"index" : "status1",
"editable" : true,
"edittype" : "select",
"editoptions" : {
"value" : ":all;initial:initial;copied:copied;filed:filed;checkit:checkit"
},
"width" : 30,
"resizable" : true,
"search" : true
}, {
"name" : "trans2",
"index" : "trans2",
"editable" : true,
"edittype" : "textarea",
"width" : 200,
"editoptions" : {
"rows" : "5"
},
"resizable" : true,
"search" : true
}, {
"name" : "status2",
"index" : "status2",
"editable" : true,
"edittype" : "select",
"editoptions" : {
"value" : ":all;2:initial;3:copied;4:filed;5:checkit"
},
"width" : 30,
"resizable" : true,
"search" : true
}],
"rowList" : [10, 20, 30, 50, 100, 1000],
"colNames" : ["<input id='cb_jqg' class='cbox' type='checkbox'/>", "ID",
"Tag name", "type", "Translation PL", "status1", "Translation EN",
"status2"],
"sortorder" : "asc",
"sortname" : "name",
"datatype" : "json",
"mtype" : "GET",
"imgpath" : "../js/jqgrid/themes/steel/images/",
"sortascimg" : "sort_asc.gif",
"sortdescimg" : "sort_desc.gif",
"firstimg" : "first.gif",
"previmg" : "prev.gif",
"nextimg" : "next.gif",
"lastimg" : "last.gif",
"altRows" : true,
"selarrrow" : [],
"savedRow" : [],
"shrinkToFit" : true,
"xmlReader" : {
"root" : "rows",
"row" : "row",
"page" : "rows>page",
"total" : "rows>total",
"records" : "rows>records",
"repeatitems" : true,
"cell" : "cell",
"id" : "[id]",
"userdata" : "userdata",
"subgrid" : {
"root" : "rows",
"row" : "row",
"repeatitems" : true,
"cell" : "cell"
}
},
"jsonReader" : {
"root" : "rows",
"page" : "page",
"total" : "total",
"records" : "records",
"repeatitems" : true,
"cell" : "cell",
"id" : "id",
"userdata" : "userdata",
"subgrid" : {
"root" : "rows",
"repeatitems" : true,
"cell" : "cell"
}
},
"subGrid" : false,
"subGridModel" : [],
"lastpage" : 1,
"lastsort" : 2,
"selrow" : null,
"beforeSelectRow" : null,
"onSelectRow" : null,
"onSortCol" : null,
"ondblClickRow" : null,
"onRightClickRow" : null,
"onPaging" : null,
"onSelectAll" : null,
"loadComplete" : null,
"gridComplete" : null,
"loadError" : null,
"loadBeforeSend" : null,
"afterInsertRow" : null,
"beforeRequest" : null,
"onHeaderClick" : null,
"viewrecords" : true,
"loadonce" : false,
"multiselect" : true,
"multikey" : false,
"editurl" : "translation_edit.php",
"search" : false,
"searchdata" : {},
"caption" : "Wydatki miesięczne",
"hidegrid" : true,
"hiddengrid" : false,
"postData" : {
"nd" : 1236783269062,
"_search" : false,
"rows" : 100,
"page" : 1,
"sidx" : "name",
"sord" : "asc"
},
"userData" : {},
"treeGrid" : false,
"treeGridModel" : "nested",
"treeReader" : {},
"ExpandColumn" : null,
"tree_root_level" : 0,
"prmNames" : {
"page" : "page",
"rows" : "rows",
"sort" : "sidx",
"order" : "sord"
},
"sortclass" : "grid_sort",
"resizeclass" : "grid_resize",
"forceFit" : false,
"gridstate" : "visible",
"cellEdit" : true,
"cellsubmit" : "clientArray",
"nv" : 0,
"loadui" : "block",
"toolbar" : [true, "top"],
"scroll" : false,
"multiboxonly" : false,
"scrollrows" : false,
"recordtext" : "Row(s)",
"loadtext" : "Loading...",
"pgtext" : "/",
"afterSaveCell" : function(rowid, name, val, iRow, iCol) {
alert('sdfsd');
},
"userdata" : "userdata",
"id" : "grid_table",
"keyIndex" : false,
"_width" : 761,
"_height" : 70
}
10:16

Moderators
30/10/2007

Hello,
Thanks for this.
I see something wrong which should be corrected when a export method is used.
There will be certain problems when one of these parameters is set to true: multiselect, subgrid, treeGrid.
The problem is that the additional columns (cb, sg and treegrid cols) generated when the grid is constructed should be removed when a export is called.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
18:24

23/03/2009

Hello,
I have spent some time trying to have the json import work.
I realized that, by default, it look for the configuration under the "grid" parameter. So it should something like:
{"grid":
{
”url” : “translation_JSON.php?nd=1236783268906″,
”height” : “100%”,
”page” : “1″,
”rowNum” : 100,
.....
.....
I hope this helps
Most Users Ever Online: 715
Currently Online:
28 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66