Reputation: 2054
I am trying out the samples for jqGrid from http://www.trirand.com/blog/jqgrid/jqgrid.html. The grid comes up with the data, but the default style (font size, height of the different blocks/rows etc) is not applied. By default style, I mean the one I see in the examples used in the trirand site.
How do I fix this?
Thanks Vivek Ragunathan
The code I used:
<html>
<head>
<title>JQGrid</title>
<link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.10.3/themes/sunny/jquery-ui.css' />
<link rel='stylesheet' type='text/css' href='http://www.trirand.com/blog/jqgrid/themes/ui.jqgrid.css' />
<script type='text/javascript' src='http://localhost:82/testbed/resources/jquery-1.7.1.min.js'></script>
<script type='text/javascript' src='http://www.trirand.com/blog/jqgrid/js/jquery-ui-custom.min.js'></script>
<script type='text/javascript' src='http://www.trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js'></script>
<script type='text/javascript' src='http://www.trirand.com/blog/jqgrid/js/jquery.jqGrid.js'></script>
<script type="text/javascript">
var lastsel2;
$(function () {
$("#list1").jqGrid({
caption: "Trying out jqGrid for Points",
url: <url>,
editurl: <edit url>,
mtype : "get",
datatype: "json",
colNames: ['id', 'Name', 'Age', 'Address'],
colModel: [
{ name:'id', index: 'id', width: 35, align:"left", editable: true, sorttype: 'int', editrules: { edithidden: true }, hidden: true },
{ name: 'name', index: 'name', width: 35, align:"left", editable: true, editoptions: { size: '20', maxlength: '255'} },
{ name: 'age', index: 'name', width: 35, align:"left", editable: true, editoptions: { size: '20', maxlength: '255'} },
{ name: 'address', index: 'address', width: 35, align:"left", editable: true, editoptions: { size: '20', maxlength: '255'} },
],
rowNum: 10,
autowidth: true,
height: 150,
rowList: [10, 20, 30, 50, 80, 100],
pager: '#pager1',
toolbar: [true,"top"],
sortname: 'created',
viewrecords: true,
altRows: true
});
$("#list1").jqGrid('navGrid', '#pager1', { edit: true, add: true, del: false });
});
}
</script>
</head>
<body>
<table id="list1"></table>
<div id="pager1"></div>
</body>
Upvotes: 0
Views: 1646
Reputation: 222017
I suppose that the reason of described problem can be missing <!DOCTYPE html ...>
line before <html>
. It's important to gives web browser clear information which version and which dialect of HTML/XHTML language you use on your page. You use <link ... />
on your page. So you tried probably to write the code in XHTML language. In the case you can use something like
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
instead of <html>
.
Moreover I would recommend you include the lines
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
at the beginning of <head>
(like in example from the documentation). If you loads other JavaScript files from the internet then you can load jQuery also from http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js
or http://code.jquery.com/jquery-1.10.1.min.js
for example.
You don't wrote which version of jqGrid you use. You should use the most resent version (currently it's 4.5.2) and includes jquery.jqGrid.min.js
or jquery.jqGrid.src.js
instead of jquery.jqGrid.js
.
I would recommend you to use gridview: true
and autoencode: true
options in all your grids. Usage of height: "auto"
seems me good too. I think that the option sortname: 'created'
was an copy&pased error. You should use the name of some existing column of the grid.
Upvotes: 1