Hi,
I have a Kendo MVC grid ajax binding. In one of the column I am displaying hyperlink using clientTemplate , when user clicks on the hyperlink it opens up another window with new controller action which is working fine too. But now the requirement when user clicks on hyperlink check user session has not expired and user still authenticated and if it is so then open up that new window otherwise clicking on hyperlink should open login controller action.
I have written a javascript function on onlcik event for <a> tag which checks if user has authenticated then open up new window else redirect to login page But its not working. when I run it I get the empty grid. Below is the code.
@(Html.Kendo().Grid<Anthology.Services.Interfaces.DTO.Web.Models.DocumentHistoryModel>()
.Name("Grid")
.EnableCustomBinding(true)
.BindTo(Model)
.Columns(columns =>
{
columns.Bound(c => c.DocumentType).Title("Document Type").Filterable(false).ClientTemplate("<a onclick=\"IsUserAuthenticated('" + "#= DocumentGuid #')\" " + " href='javascript:void(0)'>#= DocumentType#</a>");
columns.Bound(c => c.Action).Filterable(false);
columns.Bound(c => c.DocumentThumbnail).Title("Document Thumbmail").Sortable(false).Filterable(false).ClientTemplate("<text><img src='" + Url.Content("~/content/images/BDC4B60F-1EEC-4FE8-BB9C-2CA9F2F29664.png") + "' height='35' width='30' onmouseover='MagnifyImage()'/></text>");
})
.DataSource(dataSource => dataSource.Ajax()
.Read(read => read.Action("Index_Read", "Home"))
.PageSize(5)
.ServerOperation(true)
)
.Events(events => events.DataBound("onGridDataBound"))
)
function IsUserAuthenticated(documentguid) {
var userAuthenticated= @User.Identity.IsAuthenticated.ToString().ToLower();
if (userAuthenticated==true) {
var url = @Url.Action("Index", "ImageViewer") + "/" + documentguid;
$(".k-grid-content table tbody tr td text img").href = url;
$(".k-grid-content table tbody tr td text img").target = '_blank';
} else {
var urlAd= @Url.Action("Index", "Admin");
$(".k-grid-content table tbody tr td text img").href = urlAd;}
}
I have a Kendo MVC grid ajax binding. In one of the column I am displaying hyperlink using clientTemplate , when user clicks on the hyperlink it opens up another window with new controller action which is working fine too. But now the requirement when user clicks on hyperlink check user session has not expired and user still authenticated and if it is so then open up that new window otherwise clicking on hyperlink should open login controller action.
I have written a javascript function on onlcik event for <a> tag which checks if user has authenticated then open up new window else redirect to login page But its not working. when I run it I get the empty grid. Below is the code.
@(Html.Kendo().Grid<Anthology.Services.Interfaces.DTO.Web.Models.DocumentHistoryModel>()
.Name("Grid")
.EnableCustomBinding(true)
.BindTo(Model)
.Columns(columns =>
{
columns.Bound(c => c.DocumentType).Title("Document Type").Filterable(false).ClientTemplate("<a onclick=\"IsUserAuthenticated('" + "#= DocumentGuid #')\" " + " href='javascript:void(0)'>#= DocumentType#</a>");
columns.Bound(c => c.Action).Filterable(false);
columns.Bound(c => c.DocumentThumbnail).Title("Document Thumbmail").Sortable(false).Filterable(false).ClientTemplate("<text><img src='" + Url.Content("~/content/images/BDC4B60F-1EEC-4FE8-BB9C-2CA9F2F29664.png") + "' height='35' width='30' onmouseover='MagnifyImage()'/></text>");
})
.DataSource(dataSource => dataSource.Ajax()
.Read(read => read.Action("Index_Read", "Home"))
.PageSize(5)
.ServerOperation(true)
)
.Events(events => events.DataBound("onGridDataBound"))
)
function IsUserAuthenticated(documentguid) {
var userAuthenticated= @User.Identity.IsAuthenticated.ToString().ToLower();
if (userAuthenticated==true) {
var url = @Url.Action("Index", "ImageViewer") + "/" + documentguid;
$(".k-grid-content table tbody tr td text img").href = url;
$(".k-grid-content table tbody tr td text img").target = '_blank';
} else {
var urlAd= @Url.Action("Index", "Admin");
$(".k-grid-content table tbody tr td text img").href = urlAd;}
}