Ways to enhance multiple ng-repeats efficiently with css grid

Looking to create a CSS grid table with 5 columns and an undetermined number of rows. The goal is to display a pop-up element when an element in the first column is clicked, covering columns 2 through 5. This ensures that only the first column remains visible while maintaining scroll position across all columns.

The issue arises when dealing with larger datasets as the performance slows down due to multiple ng-repeats. Is there a way to consolidate these ng-repeats without sacrificing the separation of columns?

Attempting to use ng-repeat-start/end requires encapsulating data elements under a parent element, which results in auto-generated rows and cells. This restricts control over individual columns, such as setting scrollability or specific heights for the first column.

<h1>Call List</h1>
<select>
    <option ng-repeat="list in vm.list">{{list.name}}</option>
</select>
<div class="call-list-grid" ng-init="vm.selected=false;">
    <div ng-click="vm.selected = !vm.selected" id="consumers" ng-repeat-start="list in vm.listdata">
        {{list.name}}</div>
    <div ng-if="!vm.selected" ng-click="vm.selected = vm.selected" id="status">{{list.status}}</div>
    <div ng-if="!vm.selected" ng-click="vm.selected = vm.selected" id="timezone">{{list.timezone}}</div>
    <div ng-if="!vm.selected" ng-click="vm.selected = vm.selected" id="time">{{list.time}}</div>
    <div ng-if="!vm.selected" ng-click="vm.selected = vm.selected" id="guide" ng-repeat-end>{{list.guide}}</div>

    <div ng-if="vm.selected" id="selected-consumer"></div>
</div>

This snippet showcases the current code in an optimization phase.

<div class="container">
    <h1>Title header</h1>
    <select>
        <option ng-repeat="data in vm.data">{{list.name}}</option>
    </select>
    <div class="list-grid" id="grid" ng-class="{'selected' : vm.selected}"
         ng-init="vm.selected=false;">
        <div id="user" ng-class="{'user-selected' : vm.selected}">
            <div ng-click="vm.selectUser()" ng-repeat="list in vm.listdata">
               {{list.name}}
            </div>
        </div>
        <div id="status">
            <div ng-if="!vm.selected" ng-class="{'user-selected' : vm.selected}"
                 ng-repeat="list in vm.listdata">
                {{list.status}}</div>
        </div>
        <div id="timezone">
            <div ng-if="!vm.selected" ng-class="{'user-selected' : vm.selected}"
                 ng-repeat="list in vm.listdata">
                {{list.timezone}}</div>
        </div>
        <div id="time">
            <div ng-if="!vm.selected" ng-class="{'user-selected' : vm.selected}"
                 ng-repeat="list in vm.listdata">
                {{list.time}}
            </div>
        </div>
        <div id="person">
            <div ng-if="!vm.selected" ng-class="{'user-selected' : vm.selected}"
                 ng-repeat="list in vm.listdata">
                {{list.person}}
            </div>
        </div>
        <div ng-if="vm.selected" id="selected">

        </div>
    </div>
</div>
.list-grid {
    display: grid;
    grid-template-columns: auto auto auto auto auto;
    row-gap: 2px;
    height: 77vh;
    overflow-x: hidden;

    &.consumer-selected {
        overflow: hidden;
    }
}

#user {
    grid-column-start: 1;
    grid-column-end: 2;

    // height: 100vh;
    // overflow: hidden;
    &.consumer-selected {
        overflow-y: auto;
        overflow-x: hidden;
        height: 77vh;
    }
}

#status {
    grid-column-start: 2;
    grid-column-end: 3;

    &.consumer-selected {
        display: none;
    }
}

#timzone {
    grid-column-start: 3;
    grid-column-end: 4;

    &.consumer-selected {
        display: none;
    }
}

#time {
    grid-column-start: 4;
    grid-column-end: 5;

    &.consumer-selected {
        display: none;
    }
}

#person{
    grid-column-start: 5;
    grid-column-end: 6;

    &.consumer-selected {
        display: none;
    }
}

#selected{
    background-color: rgb(177, 218, 177);
    grid-column-start: 2;
    grid-column-end: 6;
    grid-row: 1 / 50;
    height: 77vh;
}

Answer №1

Hey there! Have you ever tried using the filter limitTo? It may not be the perfect solution, but it could definitely be useful for your needs. You can implement it like this:

<div class="container">
     <h1>Title header</h1>
      <select>
        <option ng-repeat="data in vm.data">{{list.name}}</option>
     </select>
    <div class="list-grid" id="grid" ng-class="{'selected' : vm.selected}" ng- 
          init="vm.selected=false;">
        <div id="user" ng-class="{'user-selected' : vm.selected}">
            <div ng-click="vm.selectUser()" ng-repeat="list in vm.listdata  | limitTo:quantity"> 
          {{list.name}}</div>
        </div>

        <!-- Other div elements here -->

        <button ng-click="getMore()">More</button>
       </div>
    </div>


//your controller 

  $scope.getMore = function(){
    $scope.quantity += 10 //or 20, 30
 }

You can even try implementing scrolling functionality with this setup.

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

Can the ::before selector be used in HTML emails?

Hey there, I have a question that might sound silly but I'm having trouble finding an answer online. My issue is with styling the bullet point before a list item in an HTML email. All I want to do is change the bullet point to a square and give it a ...

Tips for preparing HTML content with Jquery's "ON" method?

My jQuery Accordion is functioning properly, but I'm encountering issues when trying to load the accordion content dynamically from a database or JSON onto the page. The problem arises because the DOM doesn't have information about the newly inje ...

Lose yourself in the horizontal beauty of the CSS menu

Currently, I am working on an application using ASP.Net MVC4, jquery 1.9, and CSS 2.1. However, I have encountered an issue with the horizontal menu display. Whenever a form with a jquery component is shown, some buttons seem to disappear behind the menu, ...

Tips on aligning a v-btn alongside v-expansion-panels on the same row

Struggling with aligning my layout. Trying to get a single set of v-expansion-panels and a v-btn in the same row, both visually centered within a card. I managed to almost achieve it in this codepen: https://codepen.io/anzuj/pen/PoPPbdw with the following ...

Sending the value from a for loop through AJAX and populating it into a form field

Currently, I have implemented a piece of JavaScript code that captures user input, sends a request to an endpoint using AJAX, and appends a specific field from the returned results as an option within a datalist. This functionality is working perfectly fin ...

When a div is clicked, it should navigate to a different URL using AngularJS

Is there a way to redirect to a different URL when clicking on a div using AngularJS? I could use some assistance with this... Here is my HTML: <div ng-click="redirectTo()"> <p>Hello</p> </div> My JavaScript: angular.module( ...

Bootstrap datetimepicker is not showing the calendar for selecting a date, making it impossible to choose a specific date

I am facing an issue with integrating the bootstrap datetimepicker with Datatables to filter the data based on selected dates. The problem is that only an input bar is displayed on the page, and there is no calendar or calendar symbol visible. I suspect it ...

Encountering 'error: undefined' message in dropzone.js success function

I created an Angular.js directive that adds a dropzone to my app and binds a function to the success event of dropzone.js. However, I am only able to retrieve the response and the file is undefined. The response is coming from the API that uploads the file ...

Positioning of a paper-dialog in Polymer

I'm currently utilizing polymer's paper-dialog element in my application. While the dialog is always centered by default, I am looking to establish a minimum distance between the dialog and the right side of the window. This way, as the window re ...

The browser is not displaying the HTML correctly for the Polymer Paper-Menu component

I attempted to implement a paper-menu, but I am facing issues with the rendered HTML and its interaction. When I click on a menu item, the entire list disappears due to the paper-item elements not being properly placed inside a key div within the paper-men ...

Utilize JavaScript to trigger a div pop-up directly beneath the input field

Here is the input box code: <input type='text' size='2' name='action_qty' onmouseup='showHideChangePopUp()'> Along with the pop-up div code: <div id='div_change_qty' name='div_change_qty&ap ...

Ways to select the initial 10 rows, final 3 rows, and middle 2 rows using Javascript

As a newcomer to Javascript, I have a couple of questions: 1) How can I retrieve the first 10 rows, the last 3 rows, and the 2 rows in the center using the code var firstTable = $('#aaa table').eq(0); 2) Is there a way to create and assign new ...

Transforming the MVC model attribute into an HTML attribute

Is there a way to include model attributes in the HTML input tag? Code [Required] [StringLength(20)] public string Username { get; set; } [Required] [StringLength(20)] [DataType(DataType.Password)] public string Password { get; set; } Expected Output: ...

How can I eliminate unnecessary gaps in a CSS slider design?

Currently, I am in the process of learning CSS3 and attempting to create a purely CSS slider. Everything has been going smoothly until I encountered an unexpected padding or margin within my slider. After making some adjustments to the margins, the issue ...

Choosing the right jQuery selector to target a section that contains div elements

Whenever the h2 element within a section is clicked, I want all the fields in that section to be displayed. For example, if the user clicks on 'Contact Information', the three form inputs (fields) below the Contact Information heading should appe ...

Optimizing the selection and deselection of checkboxes using JQuery with X checkboxes in mind

If I have a set of 'X' checkboxes (any input elements) in a form and "M" option selection indexes ("M" less than or equal to "X"), how can I efficiently select the "M" option indexes/values and deselect the remaining checkboxes? For example, if ...

What is the best way to apply maximum height to an element using CSS?

Looking for help with my website: I made some changes in the code using Firebug and identified these elements that I want to modify (but changes are not live yet) The following code represents the elements on my site: This is the HTML code: <di ...

CSS: Struggling with Div Alignment

Here is a visual representation of the issue I am facing: View the screenshot of the rendered page here: http://cl.ly/image/0E2N1W1m420V/Image%202012-07-22%20at%203.25.44%20PM.png The first problem I have encountered is the excessive empty space between ...

What is the best way to prevent the span text from wrapping to the next line depending on the content of the previous span element using CSS?

i want to ensure the span elements text remains fixed to two lines within a flexbox. What is my goal? https://i.stack.imgur.com/k0GhL.png I am aiming to achieve something similar to the image above. The issue arises when the value in '/400' be ...

Display the div according to the $index selected from the AngularJS list

Below is the structure of my HTML code: <div class="col-md-4"> <ul class="list-group text-left"> <a href="#" class="list-group-item" ng-click="showData($index)" ng-repeat="field in Data"> {{ field.name }}</a> ...