1
2
3
4
5
6 var lastSel = -10;
7
8
9
10
11
12
13
14 $(function() {
15 $("#list").jqGrid({
16 url: '<%= ResolveUrl("~/secretLoc.aspx") %>?oper=DEMO_NAMES',
17 editurl: '<%= ResolveUrl("~/secretLoc.aspx") %>?oper=DEMO_NAME_EDIT',
18 datatype: 'json',
19 mtype: 'GET',
20 colNames: [ 'Edit', '+', 'Name Type', 'Prefix', 'First', 'Middle', 'Last', 'Suffix'],
21 colModel: [
22
23 {name:'act',index:'act',width:40,align:'center',sortable:false,formatter:'actions',
24 formatoptions:{
25
26 keys: true,
27
28 delbutton : false,
29 onEdit:function(rowid) {
30 alert("in onEdit: rowid="+rowid+"\nWe don't need return anything");
31 },
32 onSuccess:function(jqXHR) {
33
34
35 alert("in onSuccess used only for remote editing:"+
36 "\nresponseText="+jqXHR.responseText+
37 "\n\nWe can verify the server response and return false in case of"+
38 " error response. return true confirm that the response is successful");
39
40
41 return true;
42 },
43 onError:function(rowid, jqXHR, textStatus) {
44
45
46
47
48 alert("in onError used only for remote editing:"+
49 "\nresponseText="+jqXHR.responseText+
50 "\nstatus="+jqXHR.status+
51 "\nstatusText"+jqXHR.statusText+
52 "\n\nWe don't need return anything");
53 },
54 afterSave:function(rowid) {
55 alert("in afterSave (Submit): rowid="+rowid
56 +"\nWe don't need return anything");
57 },
58 afterRestore:function(rowid) {
59 alert("in afterRestore (Cancel): rowid="+rowid
60 +"\nWe don't need return anything");
61 }
62
63 }
64 },
65 { name: 'EDITME', key:true, index: 'EDITME', width: 12 },
66 { name: 'NAMETYPE', index: 'NAMETYPE', width: 65 },
67 { name: 'PREFIX', editable:true, index: 'PREFIX', edittype:'select',
68 editoptions:{value:"<%= helperClasses.utils.dataTable2JqGridEditoptions(dtNamePrefixes) %>"},
69 width: 80 },
70 { name: 'FNAME', editable:true, index: 'FNAME', width: 200 },
71 { name: 'MNAME', editable:true, index: 'MNAME', width: 300 },
72 { name: 'LNAME', editable:true, index: 'LNAME', width: 200 },
73 { name: 'SUFFIX', editable:true, index: 'SUFFIX', edittype:'select',
74 editoptions:{value:"<%= helperClasses.utils.dataTable2JqGridEditoptions(dtNameSuffixes) %>"},
75 width: 80 },
76 ],
77 pager: '#pager',
78 rowNum: 10,
79 rowList: [10, 20, 30],
80 sortname: 'p_name_prefix',
81 sortorder: 'desc',
82 viewrecords: true,
83 height: 230,
84 width: 890,
85 jsonReader: { repeatitems: false, id: "0" },
86 caption: 'All Names',
87
88
89 onSelectRow: function(id){
90 if(id && id!==lastSel && lastSel != -10){
91 jQuery(this).restoreRow(lastSel);
92 lastSel=id;
93 }
94 jQuery(this).editRow(id, true);
95 }
96
97 }).navGrid('#pager',{edit:false,add:true,addtext:"Add New Name",
98 refresh:false,del:false,search:false
99 }).navButtonAdd('#pager',{
100 caption:"Add new name", onClickButton:function(){ helloWorld("1001") },
101 position:"first"
102 })
103
104 });
Labels: jqGrid, jquery, noteToSelf