I have looked all over for the correct way to do this and cannot seem to find it. I am trying to call a javascript function inside of a template and I cannot seem to get the syntax correct. I know how to call it within a conditional statement, but how can a javascript function be called inside of the template without being a part of a conditional statement as shown below.
column.Unbound("Download").HeaderText("Download").Width("80").Template("<a href='downloadURL(${DownloadId})' title='Click to download'><img src='/images/" + "downloadIcon(${DownloadId})" + "' /></a>");
Hi Gregory,You cannot call JavaScript function inside template, but you can use formula function of the unbound column to achieve the same effect.Here is an example code:
{ headerText: "Download", key: "download", unbound: true, formula: function(data, grid) { return "<a href='" + downloadURL(data["DownloadId"]) + "' title='Click to download'><img src='/images/" + "downloadIcon(" + data["DownloadId"] +")" + "' /></a>"}}
Hope this helps,Martin PavlovInfragistics, Inc.
can you help me!!
i want to call function from column of gridview to handle process value of column, i am used to FormatterFunction but it can be only 1 paremater, i want to get other column of gridview
my code:
column.For(Function(x) x.Actions).HeaderText("Actions").width(100).Formula("CheckAction")
function CheckAction(data,grid){ return data["CusipID"]; }
it not work
I actually figured out after further investigation using your answer by doing the following.
Thanks for your help,
column.Unbound("Download").Formula("testIG");
<script>
function testIG(data,grid)
{
return data["DocumentId"];
}
</script>
Thanks for the response. This seems to be what I am looking for. I am using the grid in a MVC application. Can you tell me how this should be written in that scenario?
For instance, I have the following just to test that the javascript function testIG gets called. But it does not and I am not sure of the correct syntax as I would think it would be correct following the example you provided above.
column.Unbound("Download").HeaderText("Download").Formula("function(data,grid){return testIG(true)}");