Hi All,
I'm using the default implementation of OpportunityProducts SmartPart which has a backing OpportunityProducts.js script, which builds a Dojo DataGrid. I've added a column titled 'Version' that needs to display a custom value, depending on a database value.
I've gotten to the point where I'm trying to 'inject' custom JavaScript into the C# Form Load Action of OpportuityProducts. My current intention is to simply hide the cells to make sure the code below is working (it's not working)... The code is as follows:
String versionName = "";
String script = @require([';dojo/ready', 'dojo/aspect','Sage/UI/Forms/OpportunityProducts'],
function(ready, aspect) {
ready(function() {
aspect.after(OpportunityProducts, 'makeGrid',
function() {
var fnFormatGrid = function() {
var grid = dijit.byId('OpportunityProductsgrdOppProducts');
if(!grid){
setTimeout(fnFormatGrid, 100);
return;
}
var structure = grid.structure;
for(var i=0; i < structure[0].cells.length; i++){
var cell = structure[0].cells[i];
if(cell.field == 'OppproductId'){
";
if (String.IsNullOrEmpty(versionName))
{
// remove Version
script += "cell.hidden = true;";
}
else
{
script += "cell.name = '" + versionName + "';";
}
script += @} // if
} // for
grid.setStructure(structure);
} // fnFormatGrid
fnFormatGrid();
}); // aspect.after
}); // ready
}); // require
";
ScriptManager.RegisterStartupScript(this, GetType(), "VersionFormat",
script, true);
As far as I can tell, and from what I've researched online, using aspect.after will allow the above code to run after the specified method (makeGrid) is called. I'm trying to do this at runtime and there doesn't seem to be any injection point within the script itself...
Any help would be appreciated.