I have a subgrid column which has the code below inside subGridRowExpanded::
{ name: 'applytoall', index: 'applytoall',width: 44,
formatter:'showlink',
formatoptions:{baseLinkUrl:'mylink',
idName:'myId', addParam:'&mainGridId='+rowId}}
As you can see from code above, when a user clicks on a row in the main grid and several rows open up for the sub grid, I want to show a link in each row of the subgrid and the link should contain an ID of the parent grid as well (&mainGridId='+rowId) in this case.
However, now instead of a link Id like an image with an anchor tag and everything else to behave the same way!
I found that a custom formatter can do this in such a way:
{ name: 'mycolname', index: 'mycolname',width: 44,formatter:some}
function some (cellvalue, options, rowObject)
{
return "<a href=mylink?"
+"myId="+cellalue.rowId+"&mainGridId="+(what should go here?)
+"><img src='img/modify.gif'></a>"
}
Question
What should I put in what should go here so that I can get the ID of the row in the parentGrid.
If there is a better way to accomplish this, I’m all ears.
If I understand you correct you should just define
function someinside ofsubGridRowExpandedcallback. In the case the functionsomecan access all variables defined in outer scope. The callback functionsubGridRowExpandedhasrowIdas the second parameter and you can just use it.