www/js/profile_styles.js

changeset 486
e17155b3086a
parent 444
7e563dbbee32
child 494
af28ebe4a779
equal deleted inserted replaced
485:3cdfcdd71077 486:e17155b3086a
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function () {
46 46
47 var dataRecord = {}; 47 var dataRecord = {},
48 var url = "includes/db_profile_styles.php"; 48 url = 'includes/db_profile_styles.php',
49 49 source = {
50 // prepare the data
51 var source = {
52 datatype: "json", 50 datatype: "json",
53 cache: false, 51 cache: false,
54 datafields: [ 52 datafields: [
55 { name: 'record', type: 'number' }, 53 { name: 'record', type: 'number' },
56 { name: 'name', type: 'string' }, 54 { name: 'name', type: 'string' },
86 url: url, 84 url: url,
87 cache: false, 85 cache: false,
88 data: data, 86 data: data,
89 type: "POST", 87 type: "POST",
90 success: function (data, status, xhr) { 88 success: function (data, status, xhr) {
91 // delete command is executed.
92 commit(true); 89 commit(true);
90 location.reload( true );
93 }, 91 },
94 error: function (jqXHR, textStatus, errorThrown) { 92 error: function (jqXHR, textStatus, errorThrown) {
95 commit(false); 93 commit(false);
96 } 94 }
97 }); 95 });
104 cache: false, 102 cache: false,
105 data: data, 103 data: data,
106 type: "POST", 104 type: "POST",
107 success: function (data, status, xhr) { 105 success: function (data, status, xhr) {
108 commit(true); 106 commit(true);
107 location.reload( true );
109 }, 108 },
110 error: function(jqXHR, textStatus, errorThrown) { 109 error: function(jqXHR, textStatus, errorThrown) {
111 commit(false); 110 commit(false);
112 } 111 }
113 }); 112 });
119 url: url, 118 url: url,
120 cache: false, 119 cache: false,
121 data: data, 120 data: data,
122 type: "POST", 121 type: "POST",
123 success: function (data, status, xhr) { 122 success: function (data, status, xhr) {
124 // update command is executed.
125 commit(true); 123 commit(true);
124 location.reload( true );
126 }, 125 },
127 error: function(jqXHR, textStatus, errorThrown) { 126 error: function(jqXHR, textStatus, errorThrown) {
128 commit(false); 127 commit(false);
129 } 128 }
130 }); 129 });
168 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); 167 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 });
169 $("#profile").jqxInput({ theme: theme, width: 800, height: 48 }); 168 $("#profile").jqxInput({ theme: theme, width: 800, height: 48 });
170 $("#ingredients").jqxInput({ theme: theme, width: 800, height: 23 }); 169 $("#ingredients").jqxInput({ theme: theme, width: 800, height: 23 });
171 $("#examples").jqxInput({ theme: theme, width: 800, height: 48 }); 170 $("#examples").jqxInput({ theme: theme, width: 800, height: 48 });
172 171
173 var dataAdapter = new $.jqx.dataAdapter(source); 172 var dataAdapter = new $.jqx.dataAdapter(source),
174 var editrow = -1; 173 editrow = -1;
175 // initialize jqxGrid 174 // initialize jqxGrid
176 $("#jqxgrid").jqxGrid({ 175 $("#jqxgrid").jqxGrid({
177 width: 1280, 176 width: 1280,
178 height: 630, 177 height: 630,
179 source: dataAdapter, 178 source: dataAdapter,
180 theme: theme, 179 theme: theme,
181 showstatusbar: true, 180 showstatusbar: true,
182 renderstatusbar: function (statusbar) { 181 renderstatusbar: function (statusbar) {
183 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 182 var container, addButton, impButton;
184 var addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>"); 183 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
185 var impButton = $("<div style='float: right; margin-right: 50px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Import</span></div>"); 184 addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>");
185 impButton = $("<div style='float: right; margin-right: 50px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Import</span></div>");
186 container.append(addButton); 186 container.append(addButton);
187 container.append(impButton); 187 container.append(impButton);
188 statusbar.append(container); 188 statusbar.append(container);
189 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 189 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
190 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 190 impButton.jqxButton({ theme: theme, width: 90, height: 20 });
214 $("#ingredients").val(''); 214 $("#ingredients").val('');
215 $("#examples").val(''); 215 $("#examples").val('');
216 $("#popupWindow").jqxWindow('open'); 216 $("#popupWindow").jqxWindow('open');
217 }); 217 });
218 impButton.click(function (event) { 218 impButton.click(function (event) {
219 var url="import_ingredients.php?select=styles"; 219 window.location.href = 'import_ingredients.php?select=styles';
220 window.location.href = url;
221 }); 220 });
222 }, 221 },
223 filterable: true, 222 filterable: true,
224 filtermode: 'excel', 223 filtermode: 'excel',
225 columns: [ 224 columns: [
242 return "Wijzig"; 241 return "Wijzig";
243 }, buttonclick: function (row) { 242 }, buttonclick: function (row) {
244 // open the popup window when the user clicks a button. 243 // open the popup window when the user clicks a button.
245 editrow = row; 244 editrow = row;
246 // get the clicked row's data and initialize the input fields. 245 // get the clicked row's data and initialize the input fields.
247 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 246 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
248 $("#name").val(dataRecord.name); 247 $("#name").val(dataRecord.name);
249 $("#category").val(dataRecord.category); 248 $("#category").val(dataRecord.category);
250 $("#category_number").val(dataRecord.category_number); 249 $("#category_number").val(dataRecord.category_number);
251 $("#style_letter").val(dataRecord.style_letter); 250 $("#style_letter").val(dataRecord.style_letter);
252 $("#style_guide").val(dataRecord.style_guide); 251 $("#style_guide").val(dataRecord.style_guide);
336 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 335 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
337 } else { 336 } else {
338 $('#jqxgrid').jqxGrid('addrow', null, row); 337 $('#jqxgrid').jqxGrid('addrow', null, row);
339 } 338 }
340 $("#popupWindow").jqxWindow('hide'); 339 $("#popupWindow").jqxWindow('hide');
341 location.reload( true ); // reload ourself.
342 }); 340 });
343 createDelElements(); 341 createDelElements();
344 }); 342 });
345 343

mercurial