从数据库中获取值并使用xml显示在jqgrid表中?
这个网格函数从数据库中获取值并使用xml显示在jqgrid表中?,jqgrid,Jqgrid,这个网格函数 $(document).ready(function () { $("#gridTable").jqGrid({ url: '/Grid/CallingFunction', datatype: 'xml', colNames: ['Name', 'Empno', 'Age', 'Address', 'Contactno', 'Sal
$(document).ready(function () {
$("#gridTable").jqGrid({
url: '/Grid/CallingFunction',
datatype: 'xml',
colNames: ['Name', 'Empno', 'Age', 'Address', 'Contactno', 'Salary'],
colModel: [
{name: 'name', width: 200},
{name: 'empno', width: 100},
{name: 'age', width: 100},
{name: 'address', width: 100},
{name: 'contactno', width: 100},
{name: 'salary', width: 100}
],
rowNum: 20,
height: 400,
autoWidth: true,
rowList: [5, 10, 15],
pager: '#gridPager',
multiselect: true,
viewrecords: true,
caption: "Employee Details"
}).navGrid("#gridPager", {edit: false, add: false, del: 'deletetext;', refreshtext: 'Refresh ', searchtext: 'Find '});
});
</script>
</head>
<body>
<table id="gridTable" ></table>
<div id="gridPager"></div>
</body>
}
//这叫funtcion
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml");
try (PrintWriter out = response.getWriter()) {
ConnectionClass connectionclass = new ConnectionClass();
String xml = connectionclass.Database();
response.getWriter().write(xml);
} catch (NumberFormatException e) {
System.out.println(e);
}
}
这里有几件事。您需要使用编辑器({}按钮)中的代码格式格式化代码。此外,如果您描述了您期望发生的事情和实际发生的事情,它也会有所帮助。如何使用ajax在jqgrid中显示数据库值..使用xml或json
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml");
try (PrintWriter out = response.getWriter()) {
ConnectionClass connectionclass = new ConnectionClass();
String xml = connectionclass.Database();
response.getWriter().write(xml);
} catch (NumberFormatException e) {
System.out.println(e);
}
}