Skip to content

Commit cd55d4f

Browse files
authored
Merge pull request #201 from dkamburov/master
Update dist/npm package dependencies and readme
2 parents bd172e5 + 28ac437 commit cd55d4f

File tree

2 files changed

+236
-17
lines changed

2 files changed

+236
-17
lines changed

dist/npm/README.md

Lines changed: 233 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
#Ignite UI components for Angular 2
1+
# Ignite UI components for Angular
22

3-
Use the `igniteui.angular2.js` to taka advantage from the [Ignite UI](http://igniteui.com) controls in [Angular 2](https://angular.io/) applications. [Work with the running samples here](http://igniteui.github.io/igniteui-angular2).
3+
Use the components found in `src\igniteui.angular2.ts` to use [Ignite UI](http://igniteui.com) controls in [Angular](https://angular.io/) applications. [Work with the running samples here](http://igniteui.github.io/igniteui-angular2).
44

5-
#Requirements
5+
# Requirements
66

77
- [jQuery](http://www.jquery.com) v1.9.1 and later
88
- [jQuery UI](http://www.jqueryui.com) v1.9.0 and later
9-
- [AngularJS 2](https://angular.io/) v2.0 beta and later
9+
- [Angular](https://angular.io/) v2.0 beta and later
1010
- [Ignite UI](http://www.igniteui.com) 15.2 and later
1111

12-
#Getting Started
12+
# Running the samples
13+
To run the samples, you need [Node.js](http://nodejs.org/) installed on your machine.
14+
Afterwards, from your terminal run the following commands:
15+
16+
1. `git clone https://github.com/IgniteUI/igniteui-angular2`
17+
2. `cd igniteui-angular2`
18+
3. `npm install`
19+
4. `npm start`
20+
21+
# Getting Started
1322

1423
## Initializing controls
15-
In an Angular 2 application, Ignite UI controls support markup initialization which is done by using custom tags.
24+
In an Angular application, Ignite UI controls support markup initialization which is done by using custom tags.
1625

1726
### Custom tags
1827
Each control implements a custom tag component where the tag name is formed by splitting each capital letter in the control name with the `-` symbol.
@@ -51,8 +60,7 @@ There are two mandatory attributes that need to be set to an Ignite UI control c
5160
selector: 'my-app',
5261
template: `<ig-grid
5362
[(options)]="gridOptions"
54-
[(widgetId)]='id'></ig-grid>`,
55-
directives: [IgGridComponent]
63+
[(widgetId)]='id'></ig-grid>`
5664
})
5765
export class AppComponent {
5866
private gridOptions: IgGrid;
@@ -91,8 +99,7 @@ when there are overlapping properties. Also changing top-level attribute will ap
9199
[height]='h'
92100
[autoGenerateColumns]='true'
93101
>
94-
</ig-grid>`,
95-
directives: [IgGridComponent]
102+
</ig-grid>`
96103
})
97104
export class AppComponent {
98105
private id: string;
@@ -110,6 +117,94 @@ when there are overlapping properties. Also changing top-level attribute will ap
110117
}
111118
}
112119

120+
### Other custom tags
121+
122+
There are two custom tags `<column>` and `<features>` that are used in igGrid/igTreeGrid/igHierarchicalGrid to configure the `columns` and `features` options accordingly.
123+
124+
#### Example:
125+
126+
<ig-grid [widgetId]='id'>
127+
<column [key]="'ProductID'" [headerText]="'Product ID'" [width]="'165px'" [dataType]="'number'"></column>
128+
<column [key]="'ProductName'" [headerText]="'Product Name'" [width]="'250px'" [dataType]="'string'"></column>
129+
<column [key]="'QuantityPerUnit'" [headerText]="'Quantity per unit'" [width]="'250px'" [dataType]="'string'"></column>
130+
<column [key]="'UnitPrice'" [headerText]="'Unit Price'" [width]="'100px'" [dataType]="'number'"></column>
131+
<features>
132+
<paging [pageSize]="currPageSize"></paging>
133+
<filtering></filtering>
134+
<selection></selection>
135+
<group-by></group-by>
136+
</features>
137+
</ig-grid>
138+
139+
Each of the grids features is also represented by a custom tag.
140+
141+
#### Examples:
142+
143+
| Feature Name | Tag |
144+
|--------------------|---------------------------|
145+
| ColumnMoving | `<column-moving>` |
146+
| Filtering | `<filtering>` |
147+
| GroupBy | `<group-by>` |
148+
| Hiding | `<hiding>` |
149+
| CellMerging | `<cell-merging>` |
150+
| AppendRowsOnDemand | `<append-rows-on-demand>` |
151+
| MultiColumnHeaders | `<multi-column-headers>` |
152+
| Paging | `<paging>` |
153+
| Responsive | `<responsive>` |
154+
| Resizing | `<resizing>` |
155+
| RowSelectors | `<row-selectors>` |
156+
| Selection | `<selection>` |
157+
| Sorting | `<sorting>` |
158+
| Summaries | `<summaries>` |
159+
| ColumnFixing | `<column-fixing>` |
160+
| Tooltips | `<tooltips>` |
161+
| Updating | `<updating>` |
162+
163+
164+
### Apply new set of Control Options
165+
166+
In order to change the more options at once (or recreate the component with another set of options), the new configuration can be applied to the `options` property.
167+
168+
#### Example:
169+
170+
@Component({
171+
selector: 'my-app',
172+
template: `<ig-grid
173+
[(options)]="gridOptions"
174+
[(widgetId)]='id'></ig-grid>`
175+
})
176+
export class AppComponent {
177+
private gridOptions: IgGrid;
178+
private id: string;
179+
private data: any;
180+
181+
constructor() {
182+
this.data = Northwind.getData();
183+
this.id ='grid1';
184+
this.gridOptions = {
185+
dataSource: this.data,
186+
width: "100%",
187+
height: "400px",
188+
autoGenerateColumns: true
189+
};
190+
}
191+
192+
recreateGrid() {
193+
this.gridOptions = {
194+
dataSource: Northwind.getAnotherData(),
195+
width: "700px",
196+
autoGenerateColumns: true,
197+
features: [
198+
{ name: "Paging" }
199+
]
200+
};
201+
}
202+
}
203+
204+
In this example `options` attribute points to `gridOptions` and changing in reference will destroy the grid, combine the old options with new ones and create the grid with the combined options.
205+
Also note that the new grid will have height of 400px, even though it's not defined into the new options, because of the combination with new options.
206+
If disabling an option is required set it to `null`, `undefined`, `[]` or `{}`.
207+
113208
### Handling events
114209

115210
Binding to control events is achieved by assigning attributes where the name of the attribute is the name of the control's event name surrounded by parenthesis and the value is the name of the event handler.
@@ -122,15 +217,13 @@ Binding to control events is achieved by assigning attributes where the name of
122217
|igCombo.events.textChanged | `<ig-combo (textChanged)="textChangedHandler">` |
123218
|igDateEditor.events.keypress | `<ig-date-editor (keypress)="keypressHandler">` |
124219

125-
#### Example:
126220

127221
@Component({
128222
selector: 'my-app',
129223
template: `<ig-grid
130224
[(options)]="gridOptions"
131225
[(widgetId)]='id'
132-
(dataBind)="dataBindHandler($event)"></ig-grid>`,
133-
directives: [IgGridComponent]
226+
(dataBind)="dataBindHandler($event)"></ig-grid>`
134227
})
135228
export class AppComponent {
136229
private gridOptions: IgGrid;
@@ -162,8 +255,7 @@ Binding to igGrid* feature events is done in the control's configuration code.
162255
selector: 'my-app',
163256
template: `<ig-grid
164257
[(options)]="gridOptions"
165-
[(widgetId)]='id'></ig-grid>`,
166-
directives: [IgGridComponent]
258+
[(widgetId)]='id'></ig-grid>`
167259
})
168260
export class AppComponent {
169261
private gridOptions: IgGrid;
@@ -193,6 +285,118 @@ Binding to igGrid* feature events is done in the control's configuration code.
193285

194286
In this example igGridFiltering `dataFiltered` event is handled in the application component class.
195287

288+
## Calling Component methods
289+
290+
Component methods can be called by accessing the component from the view. For example:
291+
292+
@Component({
293+
selector: 'my-app',
294+
template: '<ig-grid #grid1
295+
[(options)]="gridOptions">
296+
<features>
297+
<paging [pageSize]="'2'"></paging>
298+
</features>
299+
</ig-grid>'
300+
})
301+
export class AppComponent {
302+
private gridOptions: IgGrid;
303+
@ViewChild("grid1") myGrid: IgGridComponent;
304+
private id: string;
305+
constructor() { ... }
306+
307+
ngAfterViewInit() {
308+
//call grid method
309+
var cell = this.myGrid.cellById(1, "Name");
310+
//call grid paging method
311+
this.myGrid.featuresList.paging.pageIndex(2);
312+
}
313+
}
314+
315+
## Using Ignite UI Angular Components inside AOT app
316+
As a starting point, you can review the [Angular documentation on the subject](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html), which provides a guide how to compile an app with AOT. Follow their instructions to AOT compile the quickstart app.
317+
318+
Once you have a running application compiled with AOT, the next step is to add the Ignite UI Components into this app. In this demo IgComboComponent is being added to the app, igCombo is an OSS widget and it is part of the ignite-ui npm package.
319+
First we need to install the required packages:
320+
- `npm install ignite-ui`
321+
- `npm install igniteui-angular2`
322+
- `npm install jquery-ui-bundle`
323+
324+
**Note**: You have to download the full Ignite UI product if you would like to use widgets which are not part of the OSS widgets. This is a [list](https://github.com/IgniteUI/ignite-ui#available-features-in-ignite-ui-open-source-version) of the controls available in the Open-source version
325+
326+
Then go to the app module and import the combo - `import 'ignite-ui/js/modules/infragistics.ui.combo.js';`. But before that add all the dependencies for it:
327+
328+
import 'jquery';
329+
import 'jquery-ui-bundle/jquery-ui.min.js';
330+
import 'ignite-ui/js/modules/infragistics.util.js';
331+
import 'ignite-ui/js/modules/infragistics.templating.js';
332+
import 'ignite-ui/js/modules/infragistics.datasource.js';
333+
import 'ignite-ui/js/modules/infragistics.ui.combo.js';
334+
335+
In addition, at the end import the IgniteUIModule:
336+
337+
import { IgniteUIModule } from 'igniteui-angular2';
338+
@NgModule({
339+
imports: [ BrowserModule, IgniteUIModule ],
340+
341+
})
342+
export class AppModule {}
343+
344+
In order to take advantage of the [Tree shaking](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#tree-shaking) the Rollup has to be set up.
345+
Open rollup-config.js, include igniteui-angular2 to `commonjs` plugin and add `namedExport` for jquery:
346+
347+
commonjs({
348+
include: ['node_modules/rxjs/**',
349+
'node_modules/igniteui-angular2/**',
350+
],
351+
namedExports: {
352+
'node_modules/jquery/dist/jquery.min.js': [ 'jquery' ]
353+
}
354+
}),
355+
356+
Additional plugin rollup-plugin-replace should be installed
357+
`npm install rollup-plugin-replace` in order to fix the offline compilation of Ignite UI util module.
358+
`this.Class` should be changed to `window.Class`, because the offline compilation is not having the same [context and this is changed to undefined](https://github.com/rollup/rollup/issues/942).
359+
360+
replace({
361+
// this is undefined for the specified context, so replace it with window to access Class
362+
include: 'node_modules/ignite-ui/js/modules/infragistics.util.js',
363+
values: { 'this.Class': 'window.Class' }
364+
}),
365+
366+
Now we are ready to use the IgComboComponent
367+
`<ig-combo [dataSource]="heroesCombo" [widgetId]="comboId" [textKey]="'name'" [valueKey]="'id'"></ig-combo>` in app.component.html
368+
And also define the used properties in AppComponent class:
369+
370+
export class AppComponent {
371+
comboId = 'combo1';
372+
showHeading = true;
373+
heroes = ['Magneta', 'Bombasto', 'Magma', 'Tornado'];
374+
heroesCombo = [{id: 0, name: 'Magneta'}, {id: 1, name:'Bombasto'}, {id: 2, name:'Magma'}, {id: 3, name:'Tornado'}];
375+
376+
toggleHeading() {
377+
this.showHeading = !this.showHeading;
378+
}
379+
}
380+
381+
At the end, apply Ignite UI styling. To achieve this, postcss plugin should be installed
382+
`npm install rollup-plugin-postcss`
383+
384+
Open rollup-config.js file and import postcss:
385+
386+
import postcss from 'rollup-plugin-postcss'
387+
388+
postcss({
389+
extensions: ['.css']
390+
}),
391+
392+
393+
[Download](https://github.com/IgniteUI/igniteui-angular2/files/975676/quickstart-igniteui-angular2-aot.zip) the modified app which uses the specified product. To run it with AOT:
394+
1. npm install
395+
2. npm run build:aot
396+
3. npm run serve
397+
398+
399+
196400
## Two-way Data Binding
197401
The following controls currently support two-way data binding:
198402

@@ -203,9 +407,22 @@ The following controls currently support two-way data binding:
203407
5. igEditors
204408
6. igTree
205409

410+
## Running tests
411+
412+
The command for running the tests is:
413+
414+
npm test
415+
416+
After that, if all tests successfully passed a code coverage for the `igniteui.angular2.ts` filse will be generated under the `./coverage` folder.
417+
418+
To see the code coverage you can open one of the html files under `./coverage/html-report/src`.
419+
420+
**Note:** The code coverage is actually being generated on the `igniteui.angular2.js` file (comes from compilation of the source .ts file). That coverage is saved under the `coverage/karma-tmp` folder.
421+
Since we need the code coverage of the `igniteui.angular2.js` file itself, we use the remap-istanbul module to remap the report from the .js file to the .ts file and save it under the `coverage/html-report` and `coverage/lcov.info`.
422+
206423
---------------------------------------
207424

208-
##What is Ignite UI?
425+
## What is Ignite UI?
209426
[![Ignite UI Logo](http://infragistics-blogs.github.io/github-assets/logos/igniteui.png)](http://www.igniteui.com)
210427

211428
[Ignite UI](http://igniteui.com/) is an advanced HTML5+ toolset that helps you create stunning, modern Web apps. Building on jQuery and jQuery UI, it primarily consists of feature rich, high-performing UI controls/widgets such as all kinds of charts, data visualization maps, (hierarchical, editable) data grids, pivot grids, enhanced editors (combo box, masked editors, HTML editor, date picker, to name a few), flexible data source connectors, and a whole lot more. Too many to list here - check out [the site](http://igniteui.com/) for more info and to [download](https://igniteui.com/download) a trial.

dist/npm/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"data grids"
2525
],
2626
"dependencies": {
27-
"@types/reflect-metadata": "^0.0.5"
27+
"@types/reflect-metadata": "^0.0.5",
28+
"@types/ignite-ui": "^0.0.4",
29+
"@types/jquery": "2.0.47"
2830
}
2931
}

0 commit comments

Comments
 (0)