Leveraging AngularJS to present vertically-stacked information with the Bootstrap Grid System

Attempting to utilize AngularJS and Bootstrap for creating a hierarchical data display has been my recent project. Thanks to the collaboration of fellow stackoverflowers, I was able to implement a smooth sliding effect using bootstrap badges to showcase categories and subcategories.

Check out this PLNKR link to see it in action: http://plnkr.co/edit/5I1pU0TZo6AjHJTbBuG9

In the provided example, we have two main categories: fruit and vegetables.

However, as I attempt to expand the number of categories, issues arise. In reality, there could be around 100 main categories that users would need to navigate through to find specific sub-categories.

My ideal scenario involves displaying the categories vertically and ensuring they interact properly when clicked:

category-1          category-26          category-51        category-76
category-2          category-27          category-52        category-77
category-3          category-28          category-53        category-78
    .                   .                    .                  .
    .                   .                    .                  .
    .                   .                    .                  .
category-24         category-49          category-74       category-99
category-25         category-50          category-75       category-100

Clicking on a category like "category-3" should reveal its subcategories in the first column, with overflows evenly distributed across other columns until balance is achieved.

In addition, I'd prefer the number of columns used for displaying data to be responsive, adapting to different devices (e.g., 2 columns on phones, 3 on tablets, 4 on desktops).

A current rough version can be viewed in this unattractive PLNKR link: http://plnkr.co/edit/jeVxDKp268WlQWzhSQU8

The use of bootstrap classes like col-xs-6 and col-md-3 in the HTML grid doesn't align with the desired vertical display, stacking elements horizontally instead.

category-1          category-2          category-3        category-4
category-5          category-6          category-7        category-8
category-9          category-10         category-11       category-12
    .                   .                    .                  .
    .                   .                    .                  .
    .                   .                    .                  .
category-93         category-94         category-95       category-96
category-97         category-98         category-99       category-100

Clicking on categories results in their subcategories being displayed similarly, causing confusion rather than clarity due to lack of vertical organization.

The current HTML structure used for category display is shown below:

<ul id="categoriesUnorderedList">
    <li ng-repeat="category in categories"
        ng-show="category.category_show"
        class="badge-slider col-xs-6 col-md-3">
        <span ng-click="categoryClicked(category)"
            class="badge {{ getBadgeClassName(category.category_type) }}"
            ng-style="getIndent(category)">
            {{category.category_name}}
        </span>
    </li>
</ul>

Are you aware of alternative approaches or solutions that may better suit this type of data layout? Can the bootstrap grid-system be adapted for such requirements? Any assistance is greatly appreciated...

Answer №1

Following the suggestion of charlietfl, I implemented css3 columns to achieve the desired effect.

The necessary css code is as follows:

ul {
-webkit-column-width: 200px;
-moz-column-width: 200px;
-o-column-width: 200px;
column-width: 200px;

-webkit-column-count: 4;
-moz-column-count: 4;
-o-column-count: 4;
column-count: 4;

list-style-type: none;

}

I also had to eliminate the bootstrap grid elements from the html:

<ul id="categoriesUnorderedList">
    <li ng-repeat="category in categories" ng-show="category.category_show" class="badge-slider">
        <span ng-click="categoryClicked(category)" class="badge {{ getBadgeClassName(category.category_type) }}" ng-style="getIndent(category)">
          {{category.category_name}}
        </span>
    </li>
</ul>

You can access the functional PLNKR here: http://plnkr.co/edit/blKAUiUT2Ql0HGMCrJb1

Answer №2

This answer is effective when the column width is set at 200px. However, it does not work as well with a column width of 600px for the same number of columns.

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

The height of the content in the polymer core-scaffold cannot be set to 100%

I am working with a polymer element that I have defined. The main objective is to make the conversation_container element have a height of 100% so that the message_box_container can be positioned at the bottom of the entire panel using position: absolute; ...

Using Python to Detect a Late-Rendered Image on a Webpage Using JSON

I'm currently in the process of reviewing a list of URLs to verify the presence of a specific image. So far, I have experimented with both selenium and beautiful soup but haven't been able to crack it. The appearance of the image is represented ...

Guide to successfully setting up a Json server and ReactJS to run simultaneously on the same port

Currently, I am facing an issue while attempting to run my React application with a JSON server as the backend API. The problem arises when trying to run them on different ports due to a CORS error. I am currently seeking advice and looking for a solutio ...

How can I adjust the position of a target point in the chase camera using THREE.js?

Recently, I've delved into the world of THREE.js and decided to create a game featuring a spaceship as the main element. Utilizing a chase camera for my model, I encountered a challenge where I needed to adjust the camera's position in relation t ...

How come my navigation item isn't positioned at the top of the window?

I'm facing an issue while trying to add a navbar with a navbar-brand to my website. It seems like the image I have included is causing the nav-items to not align properly at the top of the window. Here is a snapshot of the problem: https://i.sstatic.n ...

Conceal / Modify / Incorporate a picture

My ultimate goal is to have a hidden box and image that will be revealed based on the result of other functions. The box should change its background color, display an image, and switch images depending on the function called. I am facing two issues with ...

The Sinon stub appears to be completely ignored during the test, despite its successful use in earlier tests

I am currently testing the functionality of an express router using sinon. The first test in my code below passes without any issues, but I'm having trouble with the second test. It's not passing and I can't seem to figure out why. When I s ...

Setting a timeout within an if statement using jQuery

Having trouble understanding why this piece of code isn't functioning properly when I include setTimeOut within the if statement. Am I making a mistake, or is there a specific way to delay execution inside an if block? if ($(window).scrollTop() > ...

Creating diagonal ribbon designs can add a unique and dynamic touch to any

Can anyone help me figure out how to create a ribbon similar to the image below using CSS? I have managed to make the slanted filled box with text inside, but I am having trouble with the flaps. Check out this CodePen link for reference. ...

The Kendo UI grid encounters issues with pagination functionality after new data is inserted

I have implemented a Kendo UI grid in my AngularJS application for managing records, but I am facing an issue with pagination. Even though I have set the pageSize to 2, when I add a new record, it doesn't create a new page and instead shows the new re ...

What is the best way to create a tree structure using JavaScript with nodes that contain two arrays nested within an array?

Hey there, I don't have much experience with Javascript (I'm more familiar with C programming) but I need to create a tree structure where each node contains two arrays inside another array. Here are some C structures that might help: struc ...

Transfer images from canvas.toDataURL to nodejs

I am attempting to transfer an image from the front-end script to my server. Here is the front-end script: var img_data = canvas.toDataURL('image/jpg'); // contains screenshot image // Place a POST request here to send the image to the server F ...

The options in the dropdown menu vanish when interacting with a jQuery feature that relies on

Recently, I have found AJAX, JSON, and jQuery to be indispensable tools in my coding endeavors. The application I am working on is a replacement for a flawed one, and it is coming along nicely. Despite making progress with the AJAX method, I have encounte ...

What is the method for defining the current date variable within a .json object?

When using a post .json method to send an object, I encounter the following situation: { "targetSigningDate": "2021-09-22T21:00:00.000Z" } The "targetSigningDate" always needs to be 'sysdate'. Rather than manually c ...

Organizing outcomes from a for each function into an array using javascript

I have a form with multiple values of the same name, and I need to arrange this data in an array before sending it via AJAX. However, when I try to do this using the .push function, I encounter an error that says "Uncaught TypeError: dArray.push is not a f ...

Bootstrap - Progress Bar Display

I have a mobile application that is built using Bootstrap 3. I am currently working on creating a responsive progress indicator for the app. This indicator will consist of three to five steps, each showing an icon, step name, and status. On mobile devices, ...

What is the best way to increase the value of a variable using jQuery?

As I work on adding dates to a slider, I find myself needing to increment the values with each click. Initially, I start with the year - 2. $('#adddates').click(function() { var year = 2; $("#slider").dateRangeSlider({ bounds: { ...

Is Passport.js' serializeUser and deserializeUser functions never triggering?

Encountering an issue with Passport-local. It seems that neither serializeuser nor deserializeUser are being invoked. Upon researching similar problems on SO, it appears that many others facing this problem were not properly including bodyParser. Below is ...

Creating a Cross Fade Animation effect with the combination of CSS and JavaScript

I've been attempting to create a similar animation using html and css. Below gif shows the desired outcome I am aiming for: https://i.sstatic.net/YsNGy.gif Although I have tried the following code, I have not been able to achieve the desired result ...

AFrame: keeping an element's world position and rotation intact while reparenting

I am attempting to reassign a child element (entity) to another parent while preserving its position, rotation, and possibly size in the scene. Ideally, I would like to implement a component (let's call it "reparent") that can be added to an entity to ...