要实现jqGrid的国际化,可以按照以下步骤进行操作:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/i18n/jquery-ui-i18n.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/js/i18n/grid.locale-en.js"></script>
jQuery("#grid").jqGrid({
url:'your_data.json',
datatype: "json",
colModel: [
{ name: "id", index: "id", width: 55 },
{ name: "name", index: "name", width: 90 }
],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#pager',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: "My First Grid",
height: '100%',
autowidth: true,
shrinkToFit: false,
loadtext: "Loading...",
multiselect: true,
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
id: "id"
},
prmNames: {
page: "page",
rows: "rows",
sort: "sidx",
order: "sord",
search: "_search",
nd: "nd",
id: "id",
oper: "oper",
editoper: "edit",
addoper: "add",
deloper: "del",
subgridid: "id",
npage: null,
totalrows: "totalrows"
}
}).jqGrid('navGrid','#pager',{edit:false,add:false,del:false});
在上面的例子中,设置了loadtext
为"Loading…",这样在加载数据时会显示"Loading…"的国际化文本。
通过以上步骤,就可以实现jqGrid的国际化了。您可以根据具体需求设置更多的国际化文本和语言包文件。