It was working fine yesterday. Now the grid is empty. (i did an update at night.) But if i try from windows xp machine, both IE and FF4 load grid just fine. Everything works.
But from linux (archlinux 64 bit), neither FF4 nor Chromium load data. The grid is empty.
Obviously the problem is not in my code. It’s working fine. Something happened to FF (and Chromium ?)
Does anyone else have this problem ?
Here’s the code:
$(document).ready(function(){var lastsel,tbl=$("#tblPrintSets");
tbl.jqGrid({url:"http://192.168.1.147:3000/json/print-sets",
editurl:"http://192.168.1.147:3000/print-sets/post",
datatype:"json",height:400,
jsonReader:{repeatitems:false,id:"set_id"},
colNames:["ID","Seq #","Set name","File Name","Group Level","Exclude Attachments"],
colModel:[{name:'set_id',sortable:false,editable:false,width:40},
{name:'seq_no',sortable:false,editable:true,width:50,editoptions:{size:4},editrules:{required:true,number:true}},
{name:'set_name',sortable:false,editable:true,width:200,editoptions:{size:25},editrules:{required:true}},
{name:'file_name',sortable:false,editable:true,width:200,editoptions:{size:25},editrules:{required:true}},
{name:'group_level',sortable:false,editable:true,width:100,edittype:"select",editoptions:{value:"1:Order;2:Service List;3:Location"}},
{name:'exclude_attachments',sortable:false,editable:true,edittype:"select",editoptions:{value:"1:Yes;0:No",defaultValue:"No"}}],
onSelectRow:function(id){if(id&&id!==lastsel){tbl.jqGrid('restoreRow',lastsel);
tbl.jqGrid('editRow',id,true);lastsel=id}}});
$("#btnNewSet").click(function(){tbl.jqGrid('editGridRow',"new",{height:200,closeAfterAdd:true,recreateForm:true})})})
and here’s the json data:
{"rows":[{"exclude_attachments":"No","file_name":"inhouse","group_level":"Location","seq_no":"1","set_id":"1","set_name":"In House"},
{"exclude_attachments":"No","file_name":"client","group_level":"Order","seq_no":"2","set_id":"2","set_name":"Client Set"},
{"exclude_attachments":"No","file_name":"oc","group_level":"Service List","seq_no":"3","set_id":"3","set_name":"O.C. Set"},
{"exclude_attachments":"No","file_name":"service","group_level":"Service List","seq_no":"4","set_id":"4","set_name":"Service List Set"}]}
jqgrid version: 4.0
jquery: 1.5.2
jquery-ui: 1.8.11
EDIT: Thanks to help from Oleg, the problem is solved. It turned out i was using absolute urls for json data. And with absolute urls it must match the url you are accessing the web site. I was accessing the web site with “localhost” url on the host machine. That’s why it did not work.
How you can see here the jqGrid woks in general.
I suppose that your main problem exist because of the usage
http://192.168.1.147:3000prefix in the url. I suppose that either IP address or the port number are changed now or the web site run on the other web server. Ajax has an important restriction known under the name same origin policy. You can not get data from the server having another IP as the current web server. Even the port number should be the same. So you should never use absolute paths for theurland change it to url:”/json/print-sets” andediturl:"/print-sets/post"for example.One more remark. Your JSON data has no id information. Accidentally the ‘set_id’ values from the input data is 1,2,3. If jqGrid find no information about ids in the JSON input it use also 1,2,3… So you have no problem with the editing of the data. If some column (like ‘set_id’) contain unique id you should include
key:truein the corresponding column definition.