This uses the bootstrap-select plugin and extends it so that you can use a remote source to search.
preprocessData: function (data) {
var offences = [];
data.forEach(function (item) {
offences.push({
value: item.code,
text: item.chargeText
});
});
return offences;
},
})
}
function updatecodepicker() {
$('.stats:last .selectpicker').not('.stats-code-picker').selectpicker();
$('.stats-code-picker').selectpicker().ajaxSelectPicker({
ajax: {
url: '/offences',
dataType: 'json',
type: 'GET'
},
log: 4,
preprocessData: function (data) {
var offences = [];
data.forEach(function (item) {
offences.push({
value: item.code,
text: item.chargeText
});
});
return offences;
},
})
}
My code objects have
Id (native DB id)
Code : ie 1110
CodeText : ie Murder - Domestic
I should use the "Code" as my Db uniquie key since that number is unique - then I dont have to worry about two Codes/Id's