This is a migrated thread and some comments may be shown as answers.

[Solved] Image not displayed in template column after making an Ajax call

2 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sanjay
Top achievements
Rank 1
Sanjay asked on 07 Jul 2011, 04:08 AM
Hi,
I am using the Telerik grid to display an image column alongwith other data columns. I am also making an Ajax call for data binding to allow for a searching records.The problem is that after that Ajax call the image column doesnt display anything.
I am using the template column for displaying the image as shown below:-

columns.Template(

@<text>

 

<img alt="@item.CountryIcon" style='width:30px;height:auto' src="@Url.Content("http://url.com/" + item.CountryIcon) "/>

</text>).Title(

 

"Icon_2").Width(30);


But the image is shown after an Ajax call when I use the client template code as shown below:-

columns.Bound(b => b.CountryIcon)

.ClientTemplate(

 

" <img alt='<#= CountryIcon #>' style='width:30px;height:auto' src=" + Url.Content("http://url.com/") + "<#= CountryIcon #> />")

.Title(

 

"Icon").Width(30);

The problem with the client template code is that the image is not shown on page load and only after the Ajax call is made.



I would like someone to suggest a solution for this problem.

2 Answers, 1 is accepted

Sort by
0
Sanjay
Top achievements
Rank 1
answered on 13 Jul 2011, 07:24 AM
Can somebody post an answer to this post.
0
Sanjay
Top achievements
Rank 1
answered on 20 Jul 2011, 10:04 AM
After some search in a different direction, I finally found a link http://www.telerik.com/community/forums/aspnet-mvc/grid/grid-clienttemplate-workaround-problem.aspx which although didnt have a direct solution for the issue had a pointer towards a solution.
The crux is that we have to use

 

 

@(Html.Telerik().Grid<Model>()

instead of

@(Html.Telerik().Grid(Model)

and use a Ajax method call to fill the data.

 

 

 

 


Tags
Grid
Asked by
Sanjay
Top achievements
Rank 1
Answers by
Sanjay
Top achievements
Rank 1
Share this question
or