1 function GetGrid() {
2 var selectedRowIndex = 0;
3 var $gridTable = $("#gridTable");
4 $gridTable.jqGrid({
5 datatype: "json",
6 height: $(window).height() - 141,
7 auto true,
8 colModel: [
9 { label: '主键', name: 'pk', hidden: true },
10 { label: "表名", name: "tableName", 300, align: "left", sortable: false },
11 {
12 label: "记录数", name: "tableRows", 100, align: "center", sortable: false,
13 formatter: function (cellvalue, options, rowObject) {
14 return cellvalue + "条";
15 }
16 },
17 { label: "说明", name: "tableComment", 120, align: "left", sortable: false },
18 { label: "表分类",name: "catKindName", 100, align: "left",sortable: false},
19 { label: "分类码",name: "catCode", 0, align: "left",sortable: false,hidden:true}
20
21 ],
22 onSelectRow: function () {
23 selectedRowIndex = $("#" + this.id).getGridParam('selrow');
24 },
25 gridComplete: function () {
26 $("#" + this.id).setSelection(selectedRowIndex, false);
27 },
28 rowNum: "1000",
29 rownumbers: true,
30 shrinkToFit: false,
31 gridview: true,
32 subGrid: true,
33 subGridRowExpanded: function (subgrid_id, row_id) {
34 var tableName = $gridTable.jqGrid('getRowData', row_id)['tableName'];
35 var subgrid_table_id = subgrid_id + "_t";
36 $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "'></table>");
37 $("#" + subgrid_table_id).jqGrid({
38 url: "dataSourceTableController.do?tableStructrue",
39 postData: { dataBaseLinkId: _DataBaseLinkId, tableName: tableName },
40 datatype: "json",
41 height: 260,
42 colModel: [
43 { label: "列名", name: "columnName", index: "columnName", 300, sortable: false },
44 { label: "数据类型", name: "dataType", index: "dataType", 120, align: "center", sortable: false },
45 { label: "长度", name: "characterMaximumLength", index: "characterMaximumLength", 57, align: "center", sortable: false },
46 { label: "允许空", name: "isNullable", index: "isNullable", 58, align: "center", sortable: false },
47 { label: "主键", name: "columnKey", index: "columnKey", 57, align: "center", sortable: false },
48 { label: "默认值", name: "columnDefault", index: "columnDefault", 120, align: "center", sortable: false },
49 { label: "说明", name: "columnComment", index: "columnComment", 200, sortable: false }
50 ],
51 caption: "表字段信息",
52 rowNum: "1000",
53 rownumbers: true,
54 shrinkToFit: false,
55 gridview: true,
56 hidegrid: false
57 });
58 }
59 });
60 //查询事件
61 $("#btn_Search").click(function () {
62 getTableList();
63 });
64 $("#txt_Keyword").keydown(function () {
65 getTableList();
66 });
67 function getTableList(){
68 $gridTable.resetSelection();
69 selectedRowIndex = 0;
70 $gridTable.jqGrid('setGridParam', {
71 url: "dataSourceTableController.do?allTables",
72 postData: { dataBaseLinkId: _DataBaseLinkId, keyword: $("#txt_Keyword").val() },
73 }).trigger('reloadGrid');
74 }
75 }