trNgGrid - display or conceal columns

Hello there,

I have a query regarding trNgGrid v3.0.5 RC and handling large amounts of JSON data.

I am looking to toggle the visibility of columns in my grid based on checkbox selections.

After exploring the documentation, I noticed that by unchecking "Autodetect (fields = null or not set)," three checkboxes appear which allow me to show/hide columns.

Can you guide me on how to implement this feature? My understanding of Angular is limited.

Upon page load, I need certain checkboxes pre-checked while others remain unchecked.

I'm unsure about the correct approach here.

Thank you for your assistance.

Answer №1

To implement the fields attribute in trNgGrid, follow these steps:

<table 
   tr-ng-grid=''
   fields='displayed_fields'
   items='itemsList'>
</table>

In your controller:

$scope.displayed_fields = ['name', 'age'];

Check out this demo.

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

Creating a CSS selector element with an index is a useful skill to have when

Currently, I am in the process of developing a test application using Selenium that relies on CSS Selectors or XPath strings. One specific challenge I encountered was testing menu items that only appear upon hovering. When utilizing "Inspect Element" in bo ...

Guide to showcasing an image on an HTML page using HTTP header

I have an HTML page with a basic layout that includes a single button. When this button is clicked, it needs to trigger an HTTP request to a specific URL while including an Accept header for GET requests. The response from the HTTP URL will vary depending ...

python: basic grid of squares

Lately, I've been attempting to solve a puzzle involving a 20 by 20 square grid. Despite my efforts, I can only manage to draw 4 squares regardless of the parameters I input. If anyone could help me identify the errors in my code, it would be greatly ...

Develop an asynchronous function that can fetch a result at a later time within an Express route

I need to retrieve an Excel file from Box.com using their API and then convert the Excel data into JSON format. Afterwards, I plan to display this JSON data using Express and Handlebars. Below is the function I've created for fetching the Excel file ...

running a loop with a data-attribute conditional statement causes the browser to crash

Currently, I am working on a code snippet that involves hiding elements if the data attribute of a clicked link does not match the data attribute of a specific section. My approach is to iterate through the title elements that do not match the data attribu ...

Crafting intricate designs using AngularJS

Currently, I am developing a web application utilizing AngularJS + SpringMVC. Due to restrictions in using only pure HTML view pages, server-side frameworks like Tiles are not viable options for me. I suspect that the angularJS ng-view tag may not be robu ...

Tips for moving the title to the next line within a card design

I'm currently working on an antd Card and I am trying to figure out how to display the title on two lines if it is too long. For example, instead of showing "This title needs to go to ne...", I would like it to be split into two lines as "This title n ...

Encountering a Problem with Image Rendering in Next.js

Issue: I am facing a problem while trying to display a react component using <Gallery images={images} />. The component itself is rendered, but the images from the array are not showing up initially. However, when I resize the screen by dragging the ...

What is the best way to pass a value from one directive to another in AngularJS?

Here is the code snippet from my index.html file: <body ng-controller="MainCtrl"> <search myname="myval" change-client='client()'></search> <pagination></pagination> </body> </html> and app.js conta ...

The AJAX request was a success, but unfortunately there is no usable data available

After submitting the registration form, jQuery sends the data to register.php, which then responds with JSON data for jQuery to process. Everything seems to be functioning correctly as users are successfully registered. The network response tab shows that ...

Showing ng-repeat values in a modal

I am having trouble displaying values in a bootstrap modal when clicking on a specific story from a list of stories with images, content, and titles using ng-repeat. I have tried calling the function showStories(), but it is not working as expected. The va ...

Differentiate input elements with custom styling

I'm experiencing an issue while trying to style a specific form field in Angular 7. The style doesn't seem to be applying properly. Below is my form structure: <ul> <li> <mat-form-field *ngIf="number"> <input ma ...

Combining arrays in Angular: A step-by-step guide

Below is the provided dataset: collection = [{ date: '2020-12-01', data: [{ id: 'A1', name: 'A1', date: '2020-12-01' },{ name: 'A2', date: '2020-12- ...

Utilize the `multiselect` false attribute in conjunction with the `checkboxCell

In my current setup, I am using an ng-grid with the showSelectionCheckbox: true property along with a customized checkboxCellTemplate. If I decide to remove the checkboxCellTemplate, I achieve the desired functionality where only one checkbox can be selec ...

Adjust the position of an object in Three.js based on the scale of another object

Sharing a helpful solution for a recent problem I faced in case it can assist someone else. Imagine you have a House object with a Chair inside it positioned in a particular spot. If you scale the House's size by 2, the Chair will no longer be in the ...

Is there a way to trigger an Axios response without repeated calls or the use of a button?

As I navigate my way through using react and Axios, I encountered an issue with a get request in my code. Currently, I have a button that triggers the request when clicked, but I want to eliminate the need for this button and instead have the information d ...

The second Ajax request has been filled with successful results

Every time I press a button, an Ajax call is made which fetches data and creates a grid. The first time this function is executed, everything works perfectly - the Ajax call is successful, data is retrieved, and the grid is displayed. However, subsequent c ...

How to iterate through classes in AngularJs and assign values to models

It dawned on me that I may not be approaching or researching this correctly. My goal is to select a group of DOM elements by their class and then assign values to their ng-model attributes. To clarify in pseudo code: For each element with the class "foo" ...

What is the best way to incorporate an array of objects into the React state hook?

I have successfully retrieved data from the API in the specified format: { teamsregistered: [ { paid: false, _id: 602dea67451db71e71e4babd, name: 'MOH', mobile: '+919566879683', tag: 'JAR1NAH', __v: 0 }, { paid: false, _id: 6 ...

What can I do to ensure that the language-picker button retains the chosen value even after being clicked and the page is refreshed?

Just diving into JQuery. I've got this jquery code for a language-picker on a multi-language website. The issue is that after the page reloads in the selected language, the language picker defaults back to the original language displayed in the div t ...