I'm using AG/IG 12.3.
I am attempting to work with the Navigation Drawer Mini example and finding it difficult to introduce content into the separate navigation panes (not wanting to use routing). I have started a basic example.
The first part is the control panel will have a large number of dropdowns and some combo boxes; data will have a data grid; and charts will have a tabbed set of charts (some instances will dynamically generate many vs a static 2 for others or none for some situations). I don't know how to generate any content based on the navigation because it doesn't work like the standard navigation drawer example and there are no other examples that actually show populating something based on navigation.
The second part is that I want the data & chart navigation to show up dynamically, based on whether a button was pushed in Controls or not.
I would prefer if the title of the content is inline with the navigation drawer button to save space, as we are processing a large amount of data.
Hello Chris,
Thank you for posting to Infragistics Community!
I have been looking into your question and prepared a small sample, based on the provided by you, with the Navigation Drawer Mini. The sample demonstrates a possible approach to implementing the listed requirements, however, please feel free to modify it, according to your preferences. I have attached it below.
To render content based on the current navigation item, a pretty straightforward solution would be declaring separate container elements with the help of the ngIf structural directive. These containers could host your custom components, or any content, such as a grid.
Regarding the content title being in line with the drawer button, the igxLayout directive with igxLayoutDir="row" direction could be set on the container element of the icon and title, for example a div. “row” is actually the default direction of the directive. Optionally, additional margin style could be added, to more precisely align the title and the button.
<main igxLayout igxLayoutDir="column"> <div igxLayout igxLayoutDir="row"> <span igxButton="icon" igxToggleAction="navigation" > <igx-icon family="material">menu</igx-icon> </span> <p style="margin: 3px 20px;">{{ selected }}</p> </div> <div *ngIf="selected === 'Controls'"> <app-controls (enableGridNav)="onEnableGridNav($event)" (enableChartNav)="onEnableChartNav($event)" [gridNavEnabled]="gridEnabled" [chartNavEnabled]="chartEnabled"></app-controls> </div> <div *ngIf="selected === 'Data'"> <igx-grid [data]="sampleData" height="450px" width="550px" [autoGenerate]="true"></igx-grid> </div> <div *ngIf="selected === 'Charts'"> <app-charts></app-charts> </div> </main>
About the “Data” and “Chart” navigation items being enabled dynamically, one possible solution, as shown in the sample is to create a custom component, such as ControlsComponent to host the dropdown/buttons, etc. This component can have event emitters to subscribe to in order to enable the nav items, as well as Input properties to set their enabled state between switching the contents. Of course, there exist other possibilities, such as creating a global navigation service, however those can be considered as general Angular concepts, which are not specific to the IgniteUI for Angular library. I hope this helps point you to the right direction towards implementing your requirements.
Best regards,Bozhidara PachilovaAssociate Software Developer
5557.nav-drawer-mini.zip
I'm sure this is a fine example, but for some reason I'm unable to run it on my system. I have done a "yarn install", "npm install", and "npm install --legacy-peer-deps" and raised the memory allocation as high as 36gb and it still throws JavaScript heap errors:
PS C:\Users\csworen\Downloads\5557.nav-drawer-mini\nav-drawer-mini> npm start > example-app@0.0.0 start > node --max_old_space_size=36240 node_modules/@angular/cli/bin/ng serve -o ⠦ Generating browser application bundles (phase: emitting)... <--- Last few GCs ---> [2988:00DA6C38] 34216 ms: Mark-sweep (reduce) 1061.8 (1223.8) -> 1047.7 (1172.8) MB, 1143.6 / 0.0 ms (average mu = 0.393, current mu = 0.000) last resort GC in old space requested [2988:00DA6C38] 35349 ms: Mark-sweep (reduce) 1047.7 (1172.8) -> 1047.6 (1160.8) MB, 1133.8 / 0.0 ms (average mu = 0.239, current mu = 0.000) last resort GC in old space requested <--- JS stacktrace ---> FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I'm on Node v16.13.0, NPM v8.1.4, and my system has 48gb (23 + 16) of DDR4 memory.
Aside from that, I mentioned in my initial post that I am on 12.3 for both Angular and Infragistics. Would it be possible to get an example with that version? I don't have time to upgrade right now, with so many breaking updates.
The previously attached project is only the locally downloaded and modified StackBlitz sample you have linked and which was targeting Angular and IgniteUI for Angular version 13. I am not sure what may be causing these errors on your side as on mine, no such issues arise, however it may be the node version or other factors. By the way, no breaking changes have been introduced for the nav-drawer between versions 12.3 and ^13.x, so the suggested approach should work with no modifications for your project as well.
Additionally, it seems the latest Angular Version 12 Release is v12.2.16 (and on npm as well). Nevertheless, for your convenience, I created this StackBlitz sample with IgniteUI for Angular 12.3 demonstrating the same approach as in the previous sample.
Please, check it out and let me know if I may be of any further assistance.
Best regards, Bozhidara Pachilova
Thank you, I appreciate the example in the versions I'm working with. I'm sure this will do the trick. I'll be sure to let you know if it's missing something (or if I am).
(update) Looks good! Thanks again for the prompt responses.
Hi Chris,
Thank you for following up!
I am glad that you find the suggested approach helpful.
Thank you for using Infragistics Components.
I have a follow-up question. Is it possible to have a button appear conditionally in the drawer header?
Since the data grid is gated with a *ngIf statement, it doesn't exist unless it is the active object and that means users cannot download that grid to an Excel file unless they are actively on that drawer.
I have a good template for a button, I just need to know how to conditionally add it to the header of the "Data" drawer.
I assume that by header you mean an item in the igxDrawer variant, is this correct? I am asking this, as I do not suppose adding a button would work for the mini variant.
I have modified the sample from before to demonstrate a conditionally rendered button for the “Grid” navigation item. The property that you bind the condition to, would depend on your application-level code, for instance, the sample checks whether the item’s text property is equal to “Data”.
You mention exporting a grid to Excel, however, I am not entirely sure about the connection to the query about conditionally showing a button. If you mean that the button on the navigation group header should export a grid within one of the item’s contents to Excel, I am afraid that this is indeed not feasible, as you are right that the grid would not exist unless navigated to its nav item’s contents.
Nevertheless, in case that is your requirement, maybe the Excel Exporter service could still be leveraged if you have a hold on the data on the click of the button.
In conclusion, please, check out the above referenced sample and let me know if I can assist you with anything else on the matter.
I am glad that you were able to achieve your requirement.
Thank you for using Infragistics Components!
Best regards,Bozhidara Pachilova
Wow, another instance where I feel stupid for not being able to figure it out for myself. Thanks so much!
Thank you for clarifying.
Well, as far as I understand your requirement, I can say that you already wrote the condition to show the button, that is in case the ‘selected’ helper variable is equal to ‘Data’. I quickly updated the sample to show this.
This is valid for the sample, however, feel free to bind the condition to any logic that is relevant to your own project.
Regarding the alignment and position of the button, I guess this would be more of a styling matter.
In case I have not quite caught your requirement, please, please do provide more details.
Actually, by "header", I mean the title for each section. The portion defined as below:
<div igxLayout igxLayoutDir="row"> <span igxButton="icon" igxToggleAction="navigation"> <igx-icon family="material">menu</igx-icon> </span> <h5 style="margin: 3px 20px; color: #0071c5">{{ selected }}{{scenario1Stitch || scenario1Stitch ? ' - Stitch' : ' - Compare'}}{{ selected !== 'Controls' ? ' (' + uomParam + ')' : '' }}</h5> </div>
I'm trying to move a button conditionally into there. So if "selected" === 'data', then I'd want to see the button added to that header/title for the drawer content. Here is a diagram of what I'd like to do with it. I'd prefer to have it brought directly up, so still floating to the right, but I would be happy to have it right after the text of the content title, too.