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

DataImageUrlFields doesn't work

3 Answers 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mattia
Top achievements
Rank 2
Mattia asked on 08 Jul 2014, 10:43 AM
Hi
I'm trying to display an image in a GridImageColumn.
I tried with
DataImageUrlFields="FieldImgUrl"
where FieldImgUrl is a field of my object (FieldImgUrl = "/PHP/icon/accept.png")
but no image is shown
<telerik:GridImageColumn HeaderText="Field1" HeaderTooltip="Field1" AllowFiltering="false"
                       DataImageUrlFields="FieldImgUrl" UniqueName="Field1" ItemStyle-Width="16px" >
                       </telerik:GridImageColumn>


But if I write directly ImageUrl = "/PHP/icon/accept.png" it works...
<telerik:GridImageColumn HeaderText="Field1" HeaderTooltip="Field1" AllowFiltering="false"
                       ImageUrl="/PHP/icon/accept.png" UniqueName="Field1" ItemStyle-Width="16px" >
                       </telerik:GridImageColumn>



Thanks


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Jul 2014, 04:38 AM
Hi Stefania,

I tried your code and it works fine at my end. Please make sure the path set in the datasource is correct. Please check this article to know about the properties of GridImageColumn. Please check this example, in my db in the Photo path column I have the following value http://4.bp.blogspot.com/-djwhyOJyit8/T9b1PLKFdPI/AAAAAAAABHg/aG0_sSOi0_M/s1600/telerik_logo_RGB_photoshop.jpg , both DataImageUrlFields and ImageUrl works.

ASPX:
<telerik:GridImageColumn HeaderText="ImageColumn" DataImageUrlFields="Photopath" ImageHeight="100px" ImageWidth="82px">
</telerik:GridImageColumn>
  
<telerik:GridImageColumn HeaderText="ImageColumn" ImageUrl="http://4.bp.blogspot.com/-djwhyOJyit8/T9b1PLKFdPI/AAAAAAAABHg/aG0_sSOi0_M/s1600/telerik_logo_RGB_photoshop.jpg"  ImageHeight="100px" ImageWidth="82px">
</telerik:GridImageColumn>

Thanks,
Shinu
0
Mattia
Top achievements
Rank 2
answered on 09 Jul 2014, 07:51 AM
I tried with a full and relative path but both didn't work.
Whereas DataAlternateTextField it works..

It should be related with the fact that I use ClientDataSource?

this is the html that I see in my page
<img  id="ctl00_ContentPlaceHolder1_HomeRadGrid_ctl00_ctl06_imgBt1Asset.Bt1" src="" title="s/n: 00201" alt="s/n: 00201"></img>

this is how I populate the grid

<telerik:RadClientDataSource ID="RadClientDataSource1" runat="server" AllowBatchOperations="true">
          <ClientEvents OnChange="LoadBigMap" OnDataParse="Parse" />
        <DataSource>
            <WebServiceDataSourceSettings>
                <Select Url="load_map.asmx/GetHomeData" RequestType="Post" DataType="JSON" ContentType="application/json; charset=utf-8" />
            </WebServiceDataSourceSettings>
        </DataSource>   
        <Schema>
            <Model>
                <telerik:ClientDataSourceModelField FieldName="Id" DataType="Number" /> <telerik:ClientDataSourceModelField FieldName="Bt1ImgUrl" DataType="String" />
                <telerik:ClientDataSourceModelField FieldName="Bt1ImgToolTip" DataType="String" />
...
            </Model>
        </Schema>
 
    </telerik:RadClientDataSource>


function Parse (sender, args) {
              var data = args.get_response().d;
              for (var i = 0; i < data.length; i++) {
                  if (data[i].Code != "") {
                      data[i].Bt1ImgToolTip = "s/n: " + data[i].Bt1Asset.Bt1.Code;                       
                  }                 
              }
              args.set_parsedData(data);
          }

<telerik:RadGrid ID="HomeRadGrid" runat="server" ClientDataSourceID="RadClientDataSource1"
                EnableEmbeddedSkins="False" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True"
                Skin="MySkin" ShowGroupPanel="True" PageSize="10">
                <PagerStyle Mode="NextPrevAndNumeric" />
                <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="Id, Bt1Attribute.Latitude, Bt1Attribute.Longitude, BaloonIcon"
                    HierarchyLoadMode="Client" GroupLoadMode="Client"  EnableGroupsExpandAll="true">       
<telerik:GridImageColumn HeaderText="Field1" AllowFiltering="false" AllowSorting="false"
                            DataImageUrlFields="Bt1ImgUrl" ItemStyle-Width="16px"  DataAlternateTextField="Bt1ImgToolTip"
                            HeaderTooltip="Field1" UniqueName="Field1">
                            <ItemStyle Width="16px"></ItemStyle>
                        </telerik:GridImageColumn>
...
0
Accepted
Viktor Tachev
Telerik team
answered on 14 Jul 2014, 08:17 AM
Hello Stefania,

I have notified our developers and they will investigate what is causing the described behavior. A fix will be provided a s soon as possible. Moreover, I have logged the issue in our system and you could monitor its status in the feedback portal here. You could also vote for the item in order to increase its priority.

I apologize for any inconvenience this issue might cause you. As a token of gratitude for reporting it to us your Telerik points have been updated.


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Mattia
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Mattia
Top achievements
Rank 2
Viktor Tachev
Telerik team
Share this question
or