-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.js
115 lines (92 loc) · 3.01 KB
/
notes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// form post serializer
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
// ==============================================================
$("Form").submit(function(event) {
if ($('form').validate() == true) {
var postData = JSON.stringify($('form').serializeObject());
var formURL = $(this).attr("action");
$.ajax({
type: "post",
url: formURL,
data: postData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var SessionRecords = JSON.parse(msg.d);
},
error: function() {
alert("An error has occurred during processing your request.");
}
});
}
event.preventDefault()
});
// ============================================================================
Table = $('#Example').DataTable({
dom: 'Brltip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"aaData": SessionRecords,
"order": [
[0, "desc"]
],
"aoColumns": [{
"mDataProp": "AssetItemID",
"visible": false,
"searchable": false
}, {
"mDataProp": "SerialNumber"
}, {
"mDataProp": "PrimaryLocation"
}, {
"mDataProp": "SecondaryLocation"
}, {
"mDataProp": "LocationMoreDetail"
}, {
"mDataProp": "AssetTypeName"
}, {
"mDataProp": "AssetMakeName"
}, {
"mDataProp": "AssetModel"
}, {
"mDataProp": "ReplacementValue"
}, {
"mDataProp": "DateCreated"
}, {
"mDataProp": "UserName"
}
]
});
// use search box for filter
$('#txtSerialNumber').keyup(function() {
activeSessionTable.search($(this).val()).draw();
});
// Event: On Click - to change from add to input
$('#Example').on('click', 'tbody tr', function() {
var activeTableRow = Table.row(this).data();
$('Form').attr('action', "purchase_order_entry .aspx/editPO"); //changes the action on the form
$("#ddl option:contains(" + activeTableRow.SerialNumber + ")").attr('selected', 'selected'); //selects dropdown base on text not value
$('#txt').val(activeTableRow.Notes); // add text to textfield
$("#datepicker").datepicker('update', activeTableRow.DateRequested); //change date on datepicker
});
//===========================================================================================
//change date on datepiker
//check array of objects in a variables
$.each(obj, function (key, element) {
console.log('key: ' + key + '\n' + 'value: ' + element);
});