I'm having some trouble creating a custom formatter for one of my cells. I'm trying to add in a progress bar for a specific cell, but it seems that the html code/ javascript code is being thrown in the title rather than the actual body of the td.
Here's the code for the custom formatter.
{ name: 'StudyCacheStatus', index: 'StudyCacheStatus', width: 15, align: 'center', formatter: CacheStatusFormatter}],
function CacheStatusFormatter(cellValue, options, rowObject) {
if (typeof cellValue === 'string') { return cellValue; }
var cellValueHtml = cellValue.text;
//obviously we are adding a button
if (cellValue.buttonText) {
var buttonHtml = ' <input type="button" value="' + cellValue.buttonText + '" onclick="' + cellValue.buttonCallBack + '"/>';
cellValueHtml += buttonHtml;
}
else if (cellValue.progressBarValue)
{
var progressBarHtml = '<div id="progress-bar-' + cellValue.Uid + '>' + cellValue.progressBarValue +'</div>';
+ '<script> $( "#progress-bar-' + cellValue.Uid + '").progressbar({value:' + cellValue.progressBarValue + '});</script>';
cellValueHtml += progressBarHtml;
}
return cellValueHtml;
}
The odd part is that the input button html is added properly to the cell, even though they're being populated the same way.
<td role="gridcell" style="text-align:center;" title=" " aria-describedby="list_StudyCacheStatus">
<input type="button" value="Cache on Server" onclick="CacheStudy('12345');">
</td>
However the progress bar html ends up like this.
<td role="gridcell" style="text-align:center;" title="<div id='progress-bar-12345>5" aria-describedby="list_StudyCacheStatus"></td>
I thought it might be due to trying to force a javascript function to run in the customformatter, so I commented out the script tag, but I had the same result. What exactly am i doing wrong here? Thanks for the help!