I am loading varchar(10) values that may have leading zeroes, as key fields for lookup. In the grid the values display with the leading zeroes. When the key value is passed to the function, through the select, the zeroes are missing.
gridComplete: function () {
var ids = jQuery("#grdProductGrid").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
var rowId = $("#grdProductGrid").getRowData(cl);
be = "<a href='#'>Product</a >";
be = "<a href='#' onclick='GetProduct(" + rowId['ID'] + ")'>Product</a >";
When I get to the GetProduct function the leading zeroes are missing.
Is there a string function I am missing when I load the selects? Or should I be doing something else here
You aren’t passing the ID as a string to
GetProduct.be = "<a href='#' onclick='GetProduct(" + rowId['ID'] + ")'>Product</a >";will generate a link that looks something like this:<a href='#' onclick='GetProduct(000123)'>Product<a/>000123 isn’t a string literal there, so javascript is thinking it’s a number. Try this when creating the links:
be = "<a href='#' onclick='GetProduct(\"" + id + "\")'>Product</a >";I added the
\"in side the parentheses ofGetProduct. This will generate a link that looks like:<a href='#' onclick='GetProduct("000123")'>Product<a/>See this Fiddle: http://jsfiddle.net/gromer/deSGV/ (outputs into the console).