How to Call Rowclass Function Again on Grid Refresh Kendo Grid Angular 4

Kendo UI makes it possible to get from a bones idea to a full-fledged app, thanks to a massive component library. We're talking well over 100 components that are ready for y'all to driblet into your app at will, whether information technology'due south React, Athwart or Vue you're working in — they just work. That is considering Kendo UI is actually a packet of iv JavaScript libraries, each built natively for their respective framework. Just more than that, as nosotros've covered before, the components are super themeable to the extent that you lot can brand them whatever you want.

But here'due south the real kicker with Kendo UI: it takes intendance of the heavy lifting. The styling is great and all, but what separates Kendo UI from other component frameworks is the functionality information technology provides right out of the box.

Case in point: data. Rather than spending all your time figuring out the best way to demark information to a component, that's just a given which ultimately allows yous to focus more of your time on theming and getting the UI merely right.

Perhaps the best way to see how trivial Kendo UI makes working with data is to encounter information technology in activeness, so…

Let's look at the Angular Grid component

This is the Kendo UI for Angular Data Grid component. Lots of data in there, right? We're looking at a listing of employees that displays a name, image, and other $.25 of data about each person.

Like all of Kendo UI'southward components, it's not similar there's one information grid component that they foursquare-pegged to piece of work in multiple frameworks. This information filigree was built from scratch and designed specifically to work for Angular, just as their KendoReact Grid component is designed specifically for React.

At present, unremarkably, a simple <tabular array> element might do the flim-flam, right? But Kendo UI for Angular's data grid is chockfull of extras that make it a much ameliorate user experience. Notice right off the bat that information technology provides interactive functionality effectually things like exporting the data to Excel or PDF. And there are a bunch of other not-trivial features that would otherwise have a vast majority of the time and endeavor to brand the component.

Filtering

Here'south one for you: filtering a grid of data. Say y'all're looking at a list of employees similar the data grid example in a higher place, merely for a company that employees thousands of folks. It'd be difficult to detect a specific person without considering a slew of features, like search, sortable columns, and pagination — all of which Kendo UI's information grid does.

Users tin quickly parse the data bound to the Angular data filigree. Filtering tin be done through a dedicated filter row, or through a filter menu that pops up when clicking on a filter icon in the header of a cavalcade.

One way to filter the data is to click on a column header, select the Filter choice, and ready the criteria.

Kendo UI'southward documentation is great. Here'southward how fast nosotros tin can become this upward and running.

First, import the component

No tricks here — import the data filigree equally y'all would any other component:

                import { Component, OnInit, ViewChild } from '@angular/core'; import { DataBindingDirective } from '@progress/kendo-angular-grid'; import { process } from '@progress/kendo-data-query'; import { employees } from './employees'; import { images } from './images';              

Next, call the component

                @Component({   selector: 'my-app',   template: `     <kendo-filigree>       // ...     </kendo-filigree>   ` })              

This is incomplete, of form, because next we take to…

Configure the component

The central feature we want to enable is filtering, just Kendo's Angular Filigree takes all kinds of feature parameters that tin can be enabled in i fell swoop, from sorting and grouping, to pagination and virtualization, to proper noun a few.

Filtering? It'south a one-liner to demark it to the column headers.

                @Component({   selector: 'my-app',   template: `     <kendo-grid       [kendoGridBinding]="gridView"       kendoGridSelectBy="id"       [selectedKeys]="mySelection"       [pageSize]="twenty"       [pageable]="true"       [sortable]="true"       [groupable]="true"       [reorderable]="truthful"       [resizable]="true"       [height]="500"       [columnMenu]="{ filter: true }"     >       // etc.     </kendo-grid>   ` })              

Then, mark up the rest of the UI

We won't go deep hither. Kendo UI's documentation has an fantabulous example of how that looks. This is a practiced time to work on the styling as well, which is done in a styles parameter. Again, theming a Kendo UI component is a sure-fire.

So far, we have a nice-looking data filigree earlier we even plug any bodily data into information technology!

And, finally, bind the information

You may have noticed right away when we imported the component that we imported "employee" data in the procedure. We need to demark that data to the component. Now, this is where someone like me would get run off in a corner and cry, but Kendo UI makes it a niggling also easy for that to happen.

                // Agile the component on init export course AppComponent implements OnInit {   // Bind the employee information to the component   @ViewChild(DataBindingDirective) dataBinding: DataBindingDirective;   // Set the grid's data source to the employee data file   public gridData: whatsoever[] = employees;   // Apply the data source to the Grid component view   public gridView: any[];    public mySelection: string[] = [];    public ngOnInit(): void {     this.gridView = this.gridData;   }   // Kickoff processing the data   public onFilter(inputValue: string): void {     this.gridView = process(this.gridData, {       filter: {         // Set the type of logic (and/or)         logic: "or",         // Defining filters and their operators         filters: [           {             field: 'full_name',             operator: 'contains',             value: inputValue           },           {             field: 'job_title',             operator: 'contains',             value: inputValue           },           {             field: 'budget',             operator: 'contains',             value: inputValue           },           {             field: 'telephone',             operator: 'contains',             value: inputValue           },           {             field: 'address',             operator: 'contains',             value: inputValue           }         ],       }     }).data;      this.dataBinding.skip = 0;   }    // ... }              

Permit'due south meet that demo once more


That's a heckuva lot of ability with a minimal amount of effort. The Kendo UI APIs are extensive and plough even the about complex feature dead simple.

And nosotros didn't fifty-fifty become to all of the other wonderful goodies that nosotros become with Kendo UI components. Take accessibility. Could you lot imagine all of the consideration that needs to become into making a component like this attainable? Like all of the other powerful features nosotros get, Kendo UI tackles accessibility for us also, taking on the heavy lifting that goes into making a keyboard-friendly UI that meets WCAG 2.0 Alice standards and is compliant with Section 508 and WAI-ARIA standards.

reaganfrearraprou.blogspot.com

Source: https://css-tricks.com/building-an-angular-data-grid-with-filtering/

0 Response to "How to Call Rowclass Function Again on Grid Refresh Kendo Grid Angular 4"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel