60 datafields: [ |
60 datafields: [ |
61 { name: 'UUID', type: 'string' }, |
61 { name: 'UUID', type: 'string' }, |
62 { name: 'Name', type: 'string' }, |
62 { name: 'Name', type: 'string' }, |
63 { name: 'Steps', type: 'int' } |
63 { name: 'Steps', type: 'int' } |
64 ], |
64 ], |
|
65 id: 'UUID', |
65 url: 'getprofiles.php', |
66 url: 'getprofiles.php', |
|
67 insertrow: function (rowid, commit) { |
|
68 var data = "insert=true&" + $.param({Name: rowid}); |
|
69 $.ajax({ |
|
70 dataType: 'json', |
|
71 url: 'getprofiles.php', |
|
72 data: data, |
|
73 cache: false, |
|
74 success: function (data, status, xhr) { |
|
75 // insert command is executed. |
|
76 commit(true); |
|
77 }, |
|
78 error: function(jqXHR, textStatus, errorThrown) { |
|
79 commit(false); |
|
80 } |
|
81 }); |
|
82 }, |
|
83 deleterow: function (rowid, commit) { |
|
84 var data = "delete=true&" + $.param({UUID: rowid}); |
|
85 $.ajax({ |
|
86 dataType: 'json', |
|
87 url: 'getprofiles.php', |
|
88 data: data, |
|
89 cache: false, |
|
90 success: function (data, status, xhr) { |
|
91 // insert command is executed. |
|
92 commit(true); |
|
93 }, |
|
94 error: function(jqXHR, textStatus, errorThrown) { |
|
95 commit(false); |
|
96 } |
|
97 }); |
|
98 }, |
66 updaterow: function (rowid, rowdata, commit) { |
99 updaterow: function (rowid, rowdata, commit) { |
67 // synchronize with the server - send update command |
100 // synchronize with the server - send update command |
68 var data = "update=true&UUID=" + rowdata.UUID + "&Name=" + rowdata.Name; |
101 var data = "update=true&UUID=" + rowdata.UUID + "&Name=" + rowdata.Name; |
69 $.ajax({ |
102 $.ajax({ |
70 dataType: 'json', |
103 dataType: 'json', |
87 selectionmode: 'singlecell', |
120 selectionmode: 'singlecell', |
88 source: dataAdapter_profiles, |
121 source: dataAdapter_profiles, |
89 theme: theme, |
122 theme: theme, |
90 columnsresize: true, |
123 columnsresize: true, |
91 editable: true, |
124 editable: true, |
|
125 showstatusbar: true, |
|
126 renderstatusbar: function (statusbar) { |
|
127 // appends buttons to the status bar. |
|
128 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
129 var addButton = $("<div style='float: left; margin-left: 5px;'><img style='position: relative; margin-top: 2px;' src='../images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Add</span></div>"); |
|
130 var deleteButton = $("<div style='float: left; margin-left: 5px;'><img style='position: relative; margin-top: 2px;' src='../images/close.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Delete</span></div>"); |
|
131 var reloadButton = $("<div style='float: left; margin-left: 5px;'><img style='position: relative; margin-top: 2px;' src='../images/refresh.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Reload</span></div>"); |
|
132 container.append(addButton); |
|
133 container.append(deleteButton); |
|
134 container.append(reloadButton); |
|
135 statusbar.append(container); |
|
136 addButton.jqxButton({ width: 60, height: 20 }); |
|
137 deleteButton.jqxButton({ width: 65, height: 20 }); |
|
138 reloadButton.jqxButton({ width: 65, height: 20 }); |
|
139 // add new row. |
|
140 addButton.click(function (event) { |
|
141 /* |
|
142 * Ask a new profile name using a popup window. |
|
143 * Send "ADD PROFILE name" to the server using the getprofiles.php script. |
|
144 * Refresh the data |
|
145 */ |
|
146 $("#jqxwindow_addprofile").jqxWindow('open'); |
|
147 $("#jqxgrid_profiles").jqxGrid({ source: dataAdapter_profiles }); |
|
148 }); |
|
149 // delete selected row. |
|
150 deleteButton.click(function (event) { |
|
151 var selectedrowindex = $("#jqxgrid_profiles").jqxGrid('getselectedrowindex'); |
|
152 var rowscount = $("#jqxgrid_profiles").jqxGrid('getdatainformation').rowscount; |
|
153 var id = $("#jqxgrid_profiles").jqxGrid('getrowid', selectedrowindex); |
|
154 $("#jqxgrid_profiles").jqxGrid('deleterow', id); |
|
155 }); |
|
156 // reload grid data. |
|
157 reloadButton.click(function (event) { |
|
158 $("#jqxgrid_profiles").jqxGrid({ source: dataAdapter_profiles }); |
|
159 }); |
|
160 }, |
92 columns: [ |
161 columns: [ |
93 { text: 'UUID', editable: false, datafield: 'UUID', width: 280 }, |
162 { text: 'UUID', editable: false, datafield: 'UUID', width: 280 }, |
94 { text: 'Name', datafield: 'Name', minwidth: 120 }, |
163 { text: 'Name', datafield: 'Name', minwidth: 120 }, |
95 { text: 'Steps', editable: false, datafield: 'Steps', width: 50 } |
164 { text: 'Steps', editable: false, datafield: 'Steps', width: 50 } |
96 ] |
165 ] |
|
166 }); |
|
167 $("#jqxwindow_addprofile").jqxWindow({ |
|
168 theme: theme, |
|
169 resizable: false, |
|
170 isModal: true, |
|
171 modalOpacity: 0.5, |
|
172 autoOpen: false, |
|
173 width: 210, |
|
174 height: 180, |
|
175 cancelButton: $("#profile_cancelButton"), |
|
176 initContent: function () { |
|
177 $("#profile_addButton").jqxButton({ width: 70, height: 25, theme: theme }); |
|
178 $("#profile_cancelButton").jqxButton({ width: 70, height: 25, theme: theme }); |
|
179 $("#profile_addButton").click(function () { |
|
180 var id = $("#profile_inputField").val(); |
|
181 $("#jqxgrid_profiles").jqxGrid('insertrow', id); |
|
182 $("#jqxwindow_addprofile").jqxWindow('hide'); |
|
183 }); |
|
184 } |
97 }); |
185 }); |
98 |
186 |
99 /* |
187 /* |
100 * Units |
188 * Units |
101 */ |
189 */ |