• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

[progress News] [progress Openedge Abl] Easy Image Carousels With Rollbase And Kendo Ui

Not open for further replies.

Thierry Ciot

Learn how to use the Rollbase Kendo UI built-in image carousel without any programming, and then how to customize the carousel's data source to provide images from any location.

Get Your No-code Carousel

It's easy to get a carousel on your page with Rollbase. Simply configure a couple of image fields in your object; Rollbase will automatically group the images into an image carousel. The carousel is rendered where you have dragged the first image field on the page.

The carousel is automatically responsive on any mobile devices. On desktop, you can configure it to have a fixed size or to be responsive; when responsive, you can even specify a maximum width beyond which the carousel will not expand.

Finally, the height of the carousel is automatically computed based on the first image's aspect ratio (or proportions).

Here is an example for a travel application:

Creating a Custom Carousel

What if you want to render images from other sources than image fields in your object?

Well, with a minimum of standard JavaScript programming, you can instantiate the Rollbase carousel object with your own data source containing an array of URLs for the images to render on carousel. This gives you complete control of what to render—and how to render. Let’s look at the few lines of code you will need to go about it:

Creating the data source:

function createCarouselDataSource(){
var allImages = [];
var baseUrl = "http://www.comoestaeso.com/cams/cam7cee/marias000";
var postFix = ".jpg";
for ( var i=1; i<=nbrImg; i++ ) {
var oneImg = {};
oneImg['imageURL'] = baseUrl + i + postFix;
allImages[i-1] = oneImg;
var dataSource = {
isResponsive: true,
maxWidth: "650px",
fieldName: "myCustomCarousel1",
allImgs: allImages
return dataSource;

The data source lets you control the list of images you want to render (See lines 5 to 9). You can also control the responsive behavior on desktop and, when responsive, the max width to expand to (line 12 and 13).

Note: if you actually use this code, the images are from a live web cam and depending on your time zone you may get a black image because it's night time there :).

The second step consists of instantiating the carousel:

var dataSource = createCarouselDataSource();
var carouselContainerEl = $("#imgCarouselContainerId");
var carousel = rb.newui.sections.ImageCarouselGenerator();
carousel.append(null, dataSource, carouselContainerEl);

You simply create the object (line 2) and then render it with the data source as well as the jQuery container element in which we want the carousel to appear.

That’s all there is to it. Here is how it renders on desktop:

Here's how it renders on a smartphone:

Add and Customize a Carousel in Minutes

In conclusion, as you could see, it is very easy to add an image carousel with just point and click configuration. Rollbase also provides a high control solution where with a few lines of JavaScript you can program images carousels with images from anywhere.

PS: If you want to try these carousels in a Rollbase app, feel free to post a comment or send a note and I'll send you a complete and installable Rollbase app. Or if you have access to eap.rollbase.com, you can pick it up from the marketplace.

New to Rollbase and want to find out more? You can learn more about Rollbase here, or start a free trial below.

Try Rollbase Now

Continue reading...
Not open for further replies.