要實現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的國際化了。您可以根據具體需求設置更多的國際化文本和語言包文件。