Last active
December 11, 2015 16:49
-
-
Save jsolid/4630641 to your computer and use it in GitHub Desktop.
Siwapp: Show product description as well in AutoComplete drop-down, instead of showing only the ambiguous product reference code. Width is adjusted to accommodate long description string. If it's more than 40 characters, truncate it and append '...'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File location: siwapp/apps/siwapp/modules/common/templates/_invoiceRow.php | |
//connect the selection of a product to update the row item | |
$('#".$invoiceItemForm['product_autocomplete']->renderId()."') | |
.autocomplete('".$urlAjaxSelectProduct."', jQuery.extend({}, { | |
dataType: 'json', | |
parse: function(data) { | |
var parsed = []; | |
for (key in data) { | |
parsed[parsed.length] = { | |
data: [ | |
data[key].reference, | |
data[key].description, | |
data[key].price, | |
data[key].id | |
], | |
value: data[key].reference, | |
result: data[key].reference, | |
}; | |
} | |
return parsed; | |
}, | |
minChars: 2, | |
matchContains: true, | |
// START Custom Code ------------------------------------ | |
formatItem: function(row) { | |
return row[0] + ': ' + ((row[1] && row[1].length > 50) ? row[1].substring(0, 50) + '...' : row[1]); | |
}, | |
width: 350, | |
// END Custom Code --------------------------------------- | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment