We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add image to nested list

Thread ID:

Created:

Updated:

Platform:

Replies:

145840 Jul 10,2019 10:06 AM UTC Jul 10,2019 02:25 PM UTC ASP.NET Core - EJ 2 1
loading
Tags: ListView
Erik
Asked On July 10, 2019 10:06 AM UTC

Hello,

i would like to add images to the lines of my nested list view.

Looking at your demo https://ej2.syncfusion.com/aspnetcore/ListView/NestedList#/material, i see i can use icon, but i simply want to add images without using styling.

Thanks

Erik

Christopher Issac Sunder K [Syncfusion]
Replied On July 10, 2019 02:00 PM UTC

Hi Erik, 
 
Greetings from Syncfusion support. 
 
Instead of CSS styling, you can make use of templates to display the image/icon in the list item. In the template, we need to have img tag and use the image path in the src attribute. Here is some code snippet for your reference, 
 
@using Syncfusion.EJ2 
@section ControlsSection{ 
    @{ var template = "<div ${if(category!==null)} class = 'clearfix desc e-list-wrapper e-list-multi-line e-list-avatar' ${else} " 
      + "class = 'clearfix e-list-wrapper e-list-multi-line e-list-avatar' ${/if}> ${if(imgSrc!=='')} <img class='e-avatar' src=${imgSrc} />" 
      + "${/if} <span class='e-list-item-header'>${title} </span>" 
      + "<span class='e-list-content e-text-overflow' >${description} </span> ${if(timeStamp!=='')}  <div id='list-logo'>" 
      + "<span class='bookmark'></span> <span class='comments'></span>" 
      + "<span class='share'></span></div> <div class='timeStamp'>" 
      + "${timeStamp} </div> ${/if} </div>";} 
    <div class="control-section"> 
        <ejs-listview enable="true" id="listview_template" dataSource="ViewBag.dataSource" cssClass="e-list-template" 
                      headerTitle="Syncfusion Blog" template=@template showHeader="true" actionComplete="onComplete"> 
        </ejs-listview> 
    </div> 
} 
 
Please check with below online sample for reference, 

Please get back to us if you require any further assistance. 
 
Thanks, 
Christo 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon