Stylish tag colors in ExtJS 3 SuperBoxSelect

My SuperBoxSelect element is being populated from a remote store.

I am looking to assign a different color to each tag when it is selected. The color value for each tag comes from the store.

Currently, I am attempting to achieve this by using the following code:

displayFieldTpl: '<tpl for="."><div class="x-superbox-item" 
style="background:{color};">{text}</div>  </tpl>'

However, the tpl function creates its own elements inside the tag (which is a list element containing another element for the close button/X).

As a result, I have colored smaller boxes within the tags and the background still remains the default color.

What I actually need is a way to change the background color of the list elements themselves, not create new elements inside them. Unfortunately, tpl does not appear to be suitable for achieving this. Also, the colors are not fixed - they should be customizable later on in the configuration for each specific tag.

The HTML for it looks like the following:

<ul id="ext-gen747">
    <li id="ext-gen1001" class="x-superbox-item x-superbox-item x-superbox-item-hover">
        "TestTag2"
        <a class="x-superbox-item-close" tabindex="0" href="#" id="ext-gen1002"></a>
    </li>
</ul>

Answer №1

In order to make things easier in this scenario, you can specify classField or styleField within the combo definition.

For instance, if your color options are named (such as red, green), you can assign classField with color and define appropriate styles in CSS. To utilize styleField, you will need to establish a calculated field in each record so that it produces the correct style tag.

If needed, you can also customize the addItemBox method for further customization.

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

Encountering issues with formData in nextjs 13 due to incorrect data type

In my NextJS application, I am using the dataForm method to retrieve the values from a form's fields: export async function getDataForm(formData) { const bodyQuery = { ....... skip: formData.get("gridSkip") ...

Is there a way for me to extract and showcase the initial 10 items bearing a particular class name from a different html document on my homepage?

I am looking to extract a list of movies from an HTML file titled "movies.html". The structure of the file is as follows: <div class="movie">Content 1</div> <div class="movie">Content 2</div> <div class=" ...

The edges of shapes created with ThreeJs appear to have a fuzzy or blurred outline

Trying to create a cube in ThreeJs using Box Geometry, but encountering strange and shaky lines. Even setting wireframe to false doesn't resolve the issue, as the edges remain problematic. https://i.sstatic.net/sUPAX.png Currently utilizing WebGlRen ...

javascript retrieving JSON data through an API request from a redirected URL

I am retrieving JSON data from the Glitch API. Upon opening the link, it redirects to a different domain (the domain was changed from gomix.me to glitch.me) When using Postman for both HTTP requests, I receive identical JSON data. However, there is a d ...

Create a BezierCurve dynamically using Three.js

I'm struggling to dynamically generate a BezierCurve from arrays in JavaScript. I tried using push method, but it's not working as expected. var x = [0,10,100,220,100, etc,...]; var y = [10,0,100,200,200, etc,...]; var z = [100,220,10,0,100, etc ...

Limiting the scope of a CSS style to only apply to a specific element and all of its child

Today, I am encountering an issue with restricting the application of CSS. The <div class="parent"> <div id="childWithNoCss"> <p>No css</p> </div> <div id="childWithCss"> <p>Apply css</p> </div> </ ...

Enhance Your AG-Grid Experience with a Personalized Colorizing Pipe

I'm having an issue with my AG-Grid implementation in my app. I'm trying to use a custom color pipe that I created in one of the columns using cellRenderer. However, I'm encountering an error and I'm not sure how to fix it. Below is my ...

What methods can be used to verify that window.print() has not been overridden?

Is there a way to verify if the window.print() method is overridden using JavaScript and/or FirefoxDriver? You can prevent all print buttons on a page from functioning like this: window.print = function() { alert("Bazinga") } When this is implemented, a ...

Advancement of Loading Techniques for Enhanced 3D Rendering in Three.js

Currently, I am integrating stl files into a three.js scene through the use of the STL loader. The size of these stl files varies from 5mb to 50mb. I am seeking a solution that would allow me to gradually load/stream/increase level of detail (unsure of te ...

Securely affix two elements on a webpage using HTML, CSS, and Bootstrap

In my webpage, I have split the layout into three sections: left, middle, and right. Using bootstrap, the left and right sections are set to 3 columns each, while the middle section is 6 columns. I want only the middle section to be scrollable, while the o ...

Having trouble applying the alternate style sheet to handheld devices

For a single page, I have implemented two different style sheets. <link rel="stylesheet" href="css/lsharecomplete_mob.css" media="handheld" type="text/css" /> <link rel="stylesheet" href="css/lsharecomplete_dt.css" type="text/css" media="Screen" ...

Having trouble with redundant code while updating state in ReactJS - React JS

Currently, I am working on a prayer times web app using reactJS (nextjs). To achieve this, I first fetch the geolocation coordinates and then retrieve the city and country name based on these coordinates. Following that, I obtain the prayer times for the s ...

Difficulties encountered with CSS transitions when using the background

I stumbled upon some interesting examples on Stack Overflow about the fade effect on link hover. Curious, I decided to try it out myself and created this JSFiddle. <div class="fade"/> .fade { -o-transition: 0.3s; -moz-transition: 0.3s; -khtml-tran ...

Maximizing Efficiency: Using a Single Prototype-Instance Across Multiple HTML Pages

I have defined some Javascript "Classes" in separate files using the Prototype function as shown below: function Playlist(id, name){ this.id = id; this.name = name; } Playlist.prototype.getid = function(){return this.id;} Playlist.prototype.getn ...

What is the best way to retrieve specific information from a group of data using Mongoose?

I need assistance with extracting the number from a collection that contains only a name and a number. I also want to either change the number or store it in a variable. How can I achieve this? let dataSchema = new mongoose.Schema({ name: String ...

Develop a precompiled library for Angular applications that utilizes Ahead-of-Time (AOT) compilation technology

My Angular 5 library is packaged for consumption by other apps in their node_modules. Currently, the app is compiled Just-in-Time(JIT) using rollup and gulp. I export it as a package, and developers use it in its JIT compiled form. After researching AOT ...

``If you're looking to retrieve, modify, and display information in your Vue application with the help of

I'm facing an issue where I am trying to retrieve data using the axios get request and then updating it based on the response of another axios get request. However, I am unable to display the data from the second request. The following is a snippet o ...

Aligning an image vertically within a circular button using Bootstrap 4

Having trouble vertically aligning a plus image in the center of a circle button? I can't seem to make it work without adjusting margins. Is there a more Bootstrap-friendly way to achieve this? Below is the code snippet: .btn-circle { backgroun ...

Dragging and dropping elements onto the screen is causing them to overlap when trying

I am having trouble merging the drag and drop functionality from Angular Material with resizing in a table. Currently, both features are conflicting and overlapping each other. What I am hoping for is to automatically cancel resizing once drag and drop s ...

What is the best way to switch from using the three.js JSONLoader to the ObjectLoader?

I successfully loaded multiple files using the code below for three.js JSONLoader: <!DOCTYPE html> <html> <head> <title>Rotating Sphere</title> <meta charset="utf-8"> <!-- https://cdnjs.com/libra ...