Showing a combination of an image and text within a cell while not in editing mode

In assessing the compatibility of the Kendo UI Gantt chart with our project requirements, one specific need arises: the display of a status column as a dropdown in edit mode, featuring three statuses - Red, Green, and Yellow, accompanied by an image indicator akin to the example below:

  1. Red 2. Green 3. Yellow, along with an image indicator something like what is shown in the image below

To achieve this desired effect when editing a cell, a custom editor for the dropdown was utilized successfully:

function statusDropDownEditor(container, options) {
        $('<input data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                dataTextField: "Status",
                dataValueField: "StatusId",
                valueTemplate: '<img class="selected-value" src="#:data.Url#" alt="#:data.Status#" /><span>#:data.Status#</span>',
                template: '<img class="selected-value" src="#:data.Url#" alt="#:data.Status#" /><span>#:data.Status#</span>',
                dataSource: {
                    transport: {
                        read: function (e) {
                            // on success
                            e.success([{ Status: 'Not Started', StatusId: '0', Url: 'Image/red.png' }, { Status: 'Red', StatusId: '1', Url: 'Image/red.png' }, { Status: 'Green', StatusId: '2', Url: 'Image/red.png' }, { Status: 'Yellow', StatusId: '3', Url: 'Image/red.png' }]);
                            // on failure
                            //e.error("XHR response", "status code", "error message");
                        }
                    }
                }
            })
    }

The Gantt Column for Status appears as follows:

{ field: "status", title: "Status", editable: true, width: 150, editor: statusDropDownEditor, template: '<img class="selected-value" src="#:data.Url#" alt="#:data.Status#" /><span>#:data.Status#</span>' }

However, upon selecting an item from the dropdown and exiting edit mode, the cell's appearance changes unexpectedly:

It appears that the default cell template in read-only mode fails to render HTML and invokes the object's toString method instead. Is there a way to rectify this issue within the Kendo UI Gantt framework?

Answer №1

Today, I encountered a familiar issue where it seems that gantt columns do not have support for template properties.

To address this limitation, I took the initiative to submit a feature suggestion on the Kendo user feedback platform. With enough community support, there is a possibility that this feature may be implemented in the future.

As a temporary workaround, I found that I could prepend an image tag onto the field column like so. However, please note that this solution is not conditional and may not suit all requirements.

<div id="gantt"></div>
<script>
    $(document).ready(function() {

        var gantt = $("#gantt").kendoGantt({
            dataSource: [
              {
                id: 1,
                title: "apples",
                orderId: 0,
                parentId: null,
                start: new Date("2015/1/17"),
                end: new Date("2015/10/17"),
                summary:false,
                expanded:false
              },
              {
                id: 2,
                orderId: 1,
                parentId: null,
                title: "banana",
                start: new Date("2015/1/17"),
                end: new Date("2015/3/17"),
                summary:false,
                expanded:true
              }
            ],
            views: [
                { type: "year", selected: true }
            ],
            columns: [
                { field: "title", title: "fruit", width: 220 },
                { field: "start", title: "start", width: 80 }
            ],
        }).data("kendoGantt");

        $(".k-grid-content tbody[role='rowgroup'] tr[role='row'] td:first-child").prepend("<img href='#' alt='image here'></img>");

    });

</script>

You can find the code for the sample page on GitHub.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having difficulty retrieving cookie from fetch() response

Many times, the issue of fetching cookies from a SO response has been raised on sites like: fetch: Getting cookies from fetch response or Unable to set cookie in browser using request and express modules in NodeJS However, none of the solutions provide ...

Revamp your array elements with MongoDB - Substring replacement

Having some difficulty replacing a substring within various documents. Below is an example of one such document: { "images" : [ { "url" : "https://example/1234" }, { "url" : "https://example/afaef" }, { "url" : ...

Switching the CSS style within a basic jQuery accordion with just a click

I created a basic accordion using jQuery. It allows the user to toggle the items open and closed, and automatically closes any other active items. Check out the code snippet below: $(document).ready(function($) { $('#accordion').find(&apo ...

Is there a way to obtain a set of JSON objects from a webpage and then append each item to a row in an HTML table?

My website has a collection of JSON objects arranged in an array as follows: [ { id: 10 name : abc }, { id: 11 name : xyz } ] I am looking to display these elements in an HTML table format, similar to the illustration shown below: https:/ ...

Adjusting the styling of slick.js carousel when the slide changes

Is it feasible to change the CSS for a div on a slick.js slider change? Essentially, I want to cycle through an array of colors and set the background color of .content to that color when the slider autoplays or when a button is clicked. Am I being too amb ...

Error encountered when uploading files using Multer (Node.js and React)

I've just submitted a request from the client, and it seems to be causing some issues. Here's the code snippet that is giving me trouble: if(file){ const data = new FormData() const fileName = Date.now() + file.name data.append( ...

I would like to understand the concept behind the direction parameter in three.js Ray

I am currently working on implementing collision detection for the meshes in my Three.js scene. I find myself confused about the functionality of the Raycaster and if I am using it correctly. Below is a fiddle that illustrates the issue I am facing: // A ...

Tips for creating a unit test for a React Component utilizing the useEffect hook and asynchronous fetch

Starting from a basic create-react-app setup, I am diving into the world of unit testing to enhance my skills. The goal is to update the main App component to fetch data from a local node API and display it as a string response. However, I'm encounter ...

What are some tips for incorporating Google Maps v3 with Twitter Bootstrap?

I'm looking to incorporate Twitter Bootstrap's Tabbed Menus into a Google Maps project that is currently coded entirely in javascript. The issue I'm facing is that since Twitter relies on jQuery, I'm unsure of how to effectively utilize ...

Ways to retrieve the currently selected id from the router within the next 14 steps

I'm currently trying to extract the ID that is selected (#about, #home, #blog) or the full path (http://localhost:3000/#about, http://localhost:3000/#home) from the router. I am working with Next.js version 14.0.3 This is my approach: My current URL ...

Is there a way to retrieve keys with distinct values in an array of objects using JavaScript?

I am working with an array of Objects that contain two values: {path: '/index', ip: '123.456.789'}. Some paths and IPs are duplicated, while others form unique combinations. My goal is to determine, for each distinct path, the count of ...

What is the correct way to utilize the wordcount function with the meteorhacks:npm package?

I recently added the meteorhacks/npm package to my Meteor app so that I could utilize the Wordcount package within it. Unfortunately, I'm encountering difficulties with my method implementation. On the client-side: getWordcount = function getWord ...

Is there a way to achieve a similar effect to "object-fit: cover" for CylinderGeometry in three.js while utilizing THREE.VideoTexture()?

I'm really interested in creating something similar to this: https://i.sstatic.net/mWuDM.png Imagine the checkered background as a texture, and I want the jar to be a cylinder with that texture applied to it. My knowledge of three.js is limited, so ...

javascript code to calculate the quantity of arrays within a nested array

I am currently working on creating an if statement that will help me determine if the nested array contains only one sub-array. I specifically need to count the objects inside the removeByNames array. I am using angularJS and linq.js, trying to find out ...

Encountering bizarre HTTP response from Ajax Post in Chrome, unable to replicate problem on local environment

Utilizing a KendoUI AutoComplete component, our system is designed to retrieve data as soon as users begin entering digits. However, we are encountering issues with one specific school district. The problem arises in Chrome where users are experiencing a ...

What is the best way to update properties of an array object using a map in pure JavaScript for maximum efficiency?

Looking for an efficient solution to replace property keys in an array of objects using a map? Here's an example scenario: // Consider an array of objects: var records = [ {"Id": "0035w000036m j7oAAA", "Business Phone": ...

Utilize AngularJS $sanitize to convert characters into HTML code

When attempting to decode characters using $sanitize, I encountered a problem. I must use the $sanitize service instead of ng-bind-html, yet I am getting different results with each one. Despite ng-bind-html utilizing $sanitize internally, the outputs are ...

Exploring the Functionality of ngMousedown and ngMouseup in AngularJS

Is it viable to apply ngMousedown to add a class to a div, and then use ngMouseup to remove the class once more? Currently, I am utilizing ng-mousedown="activateClass()". Within the activateClass() function, I modify $scope.className="data-active", which i ...

AngularJS Skype URI Button Problem

Implementing a Skype button in my project using AngularJS has been challenging. Here is the code I am currently working with: HTML: <script type="text/javascript" src="http://www.skypeassets.com/i/scom/js/skype-uri.js"></script> <skype-ui ...

Having difficulty accessing the $root variable in Vue.js

Within my app, there is a root page featuring a Navbar component. I am attempting to access a variable called currentRoute from this Navbar component. The code in my index.js file where I have defined currentRoute is as follows: import Vue from 'vue& ...