Reputation: 77
The problem is this, while developing the application I did several run test, and jqGrid worked really well, ie on the local server everything worked fine, but now I'm testing the application on a server and it no longer works because all grids are empty. I thought it was a problem with the database, but checked the Json string and this is correct. If I put the url: myOrg/Home
grid is shown empty, and if I put myOrg/Home/GridData
shows the Json format data, correctly ... what is happening ...?? why the data isn't show in the grid..?? locally everything worked like a charm, will I need any additional library in to the server.. or something ..?
Please help me.
Thanks in advance.
EDIT:
Here's the javascript I´m using
<script type="text/javascript">
$(document).ready(function () {
var lastsel;
$(function () {
jQuery('#list').jqGrid({
url: '@Url.Action("GridData", "Contacto")',
editurl: '@Url.Action("EditData", "Contacto")',
datatype: 'json',
height: 250,
colNames: ['Id', 'Nombre', 'Teléfono', 'e-mail', 'Empresa'],
colModel: [
{ name: 'Id', index: 'Id', width: 50 },
{ name: 'Nombre', index: 'Nombre', width: 100, sortable: true, editable: true, edittype: "text", editoptions: { size: "15", maxlength: "20"} },
{ name: 'Telf', index: 'Telf', width: 80, editable: true, edittype: "text", editoptions: { size: "10", maxlength: "15"} },
{ name: 'Email', index: 'Email', width: 100, editable: true, edittype: "text", editoptions: { size: "15", maxlength: "20"} },
{ name: 'Empresas', index: 'Empresas', width: 100, editable: true, edittype: "select", editoptions: { dataUrl: '/Contacto/ListaEmpresas/'} }
],
caption: 'Listado de Contactos',
onCellSelect: function (rowid, iCol, cellcontent, e) {
if (rowid && rowid !== lastsel) {
jQuery('#list').restoreRow(lastsel);
lastsel = rowid;
}
jQuery('#list').editRow(rowid, true, iCol);
},
autowidth: true,
rowNum: 10,
rowList: [10, 20, 30],
pager: '#pager',
sortname: 'id',
sortable: true,
loadonce: true,
viewrecords: true,
sortorder: 'asc'
});
jQuery('#list').jqGrid('navGrid', '#pager', { edit: true, add: true, del: true, search: true },
{ url: '@Url.Action("EditData", "Contacto")',
closeAfterEdit: true
},
{ url: '@Url.Action("AddData", "Contacto")',
closeAfterAdd: true,
closeOnEscape: true,
width: 500,
modal: true,
addCaption: 'Añadir nuevo Contacto',
reloadAfterSubmit: true,
drag: true
},
{ url: '@Url.Action("DeleteData", "Contacto")',
closeAfterDelete: true,
deleteCaption: 'Borrar Registro',
reloadAfterSubmit: true
},
{ closeAfterSearch: true,
reloadAfterSubmit: true
}
);
});
});
</script>
And here the server side code that generates the json String:
public ActionResult GridData(string sidx, string sord, int? page, int? rows)
{
List<Contacto> contactos = new List<Contacto>();
contactos = ContactoRepository.GetAll().ToList<Contacto>();
int pageIndex = Convert.ToInt32(page) - 1;
int totalrecords = contactos.Count();
//int totalpages = (int)Math.Ceiling((decimal)totalrecords / (decimal)rows);
var jsonData = new
{
sidx = "Id",
sord = "asc",
//total = totalpages,
page = page,
records = totalrecords,
rows = (
from ct in contactos
select new
{
id = ct.Id,
cell = new string[]
{
ct.Id.ToString(),
ct.Nombre,
ct.Telf,
ct.Empresas.Nombre,
}
}).ToArray(),
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
Upvotes: 0
Views: 936
Reputation: 19
sb.Append("<cell>");
sb.Append("<! [CDATA [" + g.Name + "]");
sb.Append("]> </ cell>");
I had the same problem. The exhibited jqgrid not return XML. I noticed that the registry database had some special characters like "&". The problem was the browser. Decided as follows by placing the CDATA tag field return in XML.
Upvotes: 1
Reputation: 181
This is not a direct answer but if it works under your local server, it should work under a remote server given that the remote site has the same or compatible services. If all you've done is move the application to the remote server, it would appear that you have the url path set incorrectly to the remote server.
"GridData" appears to point to the folder where your app is.
Sorry about this non-answer. I would have put it as a note under your post like you and verofairy have done but i don't know how to do that yet.
Also, if you think i'm way off base, just delete my answer.
Upvotes: 0