<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by surya prakash on Medium]]></title>
        <description><![CDATA[Stories by surya prakash on Medium]]></description>
        <link>https://medium.com/@tumma.suryaprakash?source=rss-2ceec3733f0e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KVMVv_CiFeU2SiqF</url>
            <title>Stories by surya prakash on Medium</title>
            <link>https://medium.com/@tumma.suryaprakash?source=rss-2ceec3733f0e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 19:09:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tumma.suryaprakash/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AG-Grid Editors Visible without click]]></title>
            <link>https://medium.com/@tumma.suryaprakash/ag-grid-editors-visible-without-click-b22a43ef785f?source=rss-2ceec3733f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b22a43ef785f</guid>
            <category><![CDATA[ag-grid]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[grid]]></category>
            <dc:creator><![CDATA[surya prakash]]></dc:creator>
            <pubDate>Thu, 29 Dec 2022 09:03:12 GMT</pubDate>
            <atom:updated>2022-12-29T09:03:12.456Z</atom:updated>
            <content:encoded><![CDATA[<p>Most familiar functionality of grid editors is <strong>USER </strong>should click on the cell to enable the editing and on focus out of the cell, editor will get closed. Every time we need to educate user to click on the cell to enable the editing and involves lot of clicks.</p><p>How about if the form fields are visible on the grid cell?</p><p>There is no such straight through feature in AG-Grid, But we can make use of ag-cell renders to get this done. Lets see how I have done. Below use case is just an idea , Since it is not straight through most probably it can refine and it is recommend only when user wish to view the field on the grid cell without click.</p><p>Lets first see the demo .</p><p><a href="https://stackblitz.com/edit/angular-ivy-ck8dw2?file=src/app/app.component.ts">Angular Ivy (forked) - StackBlitz</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*p80s7iYPAn13I3fdTyo97A.gif" /></figure><p>Lets see how I did this.</p><p>First I have created a component cell-editor and implemented the interface <strong>ICellRendererAngularComp, </strong>By this we need to override the methods<strong> </strong>agInit and refresh methods. Refer the below snippet.</p><pre>import { Component, OnInit } from &#39;@angular/core&#39;;<br>import { ICellRendererAngularComp } from &#39;ag-grid-angular&#39;;<br>import { ICellRendererParams } from &#39;ag-grid-community&#39;;<br><br>@Component({<br>  selector: &#39;app-cell-editor&#39;,<br>  templateUrl: &#39;./cell-editor.component.html&#39;,<br>  styleUrls: [&#39;./cell-editor.component.css&#39;],<br>})<br>export class CellEditorComponent implements OnInit, ICellRendererAngularComp {<br>  value = &#39;&#39;;<br>  params;<br>  constructor() {}<br><br>  ngOnInit() {}<br><br>  agInit(params: ICellRendererParams&lt;any, any&gt;): void {<br>    this.params = params;<br>    this.value = params.value;<br>  }<br><br>  refresh(params: ICellRendererParams&lt;any, any&gt;): boolean {<br>    return;<br>  }<br><br>  onModelChange() {<br>    this.params.data[this.params.colDef.field] = this.value;<br>  }<br>}<br><br>// Template<br><br><br>&lt;input<br>  type=&quot;text&quot;<br>  class=&quot;ag-input-field-input ag-text-field-input&quot;<br>  [(ngModel)]=&quot;value&quot;<br>  (ngModelChange)=&quot;onModelChange()&quot;<br>/&gt;</pre><p>Refer the component code .</p><pre><br>@Component({<br>  selector: &#39;my-app&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;],<br>})<br>export class AppComponent {<br>  frameworkComponents: any = {<br>    cellEditor: CellEditorComponent,<br>  };<br><br>  value = &#39;test&#39;;<br>  columnDefs: ColDef[] = [<br>    { field: &#39;make&#39; },<br>    {<br>      field: &#39;price&#39;,<br>      cellRenderer: &#39;cellEditor&#39;,<br>      cellRendererParams: {},<br>    },<br>    { field: &#39;model&#39; },<br>  ];<br><br>  rowData = [<br>    { make: &#39;Toyota&#39;, model: &#39;Celica&#39;, price: 35000 },<br>    { make: &#39;Ford&#39;, model: &#39;Mondeo&#39;, price: 32000 },<br>    { make: &#39;Porsche&#39;, model: &#39;Boxster&#39;, price: 72000 },<br>  ];<br>}</pre><p>If you see I have created a custom render in which I have returned a input field, By this it is rendering the input field on top of the cell.</p><p>Since this is customized I manually mapped cell data to input field using ngModel, aginit method will trigger for every row and we will get data in the argument params.</p><p>On every change I am updating the row data in ngModelChange method.</p><p>This is a simple example, We can add multiple features and make use of cellRendererParams config to pass customized parameters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b22a43ef785f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make elements disable using angular custom directive]]></title>
            <link>https://medium.com/@tumma.suryaprakash/make-elements-disable-using-angular-custom-directive-29333e296993?source=rss-2ceec3733f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/29333e296993</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-directive]]></category>
            <category><![CDATA[user-roles]]></category>
            <dc:creator><![CDATA[surya prakash]]></dc:creator>
            <pubDate>Thu, 21 May 2020 07:44:39 GMT</pubDate>
            <atom:updated>2020-05-21T09:53:46.589Z</atom:updated>
            <content:encoded><![CDATA[<p>When we have a large set of components and making elements disabled based on roles(View only )is quite mundane. I have encountered the same where I need to make all elements in a page to disable based on role and entitlements are specific to the record. The pain point here is I need to pass entitlement info to each and every component. So I decided to make a directive which will identify all the form , buttons elements and make them disable.</p><p>Find my directive in the below section and I will explain how the directive works</p><pre>import { Directive, ElementRef, Input, OnInit, OnChanges, SimpleChanges } from ‘@angular/core’;</pre><pre>@Directive({</pre><pre>selector: ‘[disable-elements]’</pre><pre>})</pre><pre>export class DisableDirective implements OnChanges {</pre><pre>  @Input()<br>  disable = false;</pre><pre>  elementTypes = [‘input’, ‘select’, ‘button’];</pre><pre>  constructor(private _el: ElementRef) { }</pre><pre>  ngOnChanges(changes: SimpleChanges): void {<br>    const elements = this.getElements();<br>    this.doReadOnly(elements);<br>  }</pre><pre>  getElements() {<br>    const elements =    this._el.nativeElement.<br>         querySelectorAll(this.elementTypes.join(‘,’));<br>    return elements;<br>  }</pre><pre>  doReadOnly(elements) {<br>    for (let i = 0; i &lt; elements.length; i++) {<br>      elements[i].disabled = this.disable;<br>    }<br>  }</pre><pre>}</pre><p>We have input with name <strong>disable </strong>and it has two values true or false based on the value all the elements underlying the parent will disabled or enabled.</p><p><strong>elementTypes: </strong>class member will holds which element types under the parent need to disabled. I have passed input , select and button.</p><p>In the life cycle hook ngOnchanges I am calling two functions getElements and doReadOnly lets discuss on this methods.</p><p><strong>getElements </strong>: This method will query the elementTypes list under the parent and returns all the matching elements and this elements can be used to make disable.</p><p><strong>doReadOnly</strong>: This method will iterates over the elements returned by getelements method and it will assign the disable input value to element disabled attribute. Based on the input value from parent it will disable/enables the elements.</p><p>Lets see some example on usage.</p><pre>&lt;div disable-elements [disable]=”’true’”&gt;</pre><pre>  &lt;input type=”text” /&gt;</pre><pre>  &lt;input type=’checkbox’ /&gt;</pre><pre>  &lt;select name=”” id=””&gt;</pre><pre>  &lt;option value=””&gt;Test&lt;/option&gt;</pre><pre>  &lt;/select&gt;</pre><pre>  &lt;button&gt;Test&lt;/button&gt;</pre><pre>&lt;/div&gt;</pre><p>Here we have a div with form elements as child&#39;s. I have passed the directive and with input value as true. So the directive making all the elements to disable.</p><p>Thank you for your time I am beginner to medium and writing blogs . Please leave your feedback on this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29333e296993" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drop down tree-view in angular using prime ng tree]]></title>
            <link>https://medium.com/@tumma.suryaprakash/drop-down-tree-view-in-angular-using-prime-ng-tree-747800fed522?source=rss-2ceec3733f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/747800fed522</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[dropdownlist]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[dropdown]]></category>
            <category><![CDATA[primeng]]></category>
            <dc:creator><![CDATA[surya prakash]]></dc:creator>
            <pubDate>Mon, 30 Dec 2019 14:09:20 GMT</pubDate>
            <atom:updated>2019-12-30T14:09:20.391Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Drop down tree-view in angular using prime ng tree</strong></p><p>I would like to create a drop down tree view using p-tree(prime ng). This article includes creation of reusable component which has drop down tree-view . Before getting started please see the demo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*oPZVlHYrZ1hg3auI4o_GTA.gif" /></figure><p>Lets check the source code of dropdown tree view component and it follows with template and scss file.</p><pre>import { Component, OnInit, ViewChild, ElementRef, Input, Output, ViewEncapsulation } from &#39;@angular/core&#39;;</pre><pre>import { TreeNode } from &#39;primeng/api/treenode&#39;;</pre><pre>import { EventEmitter } from &#39;@angular/core&#39;;<br>@Component({<br>  selector: &#39;dropdown-treeview&#39;,<br>  templateUrl: &#39;./dropdown-treeview.component.html&#39;,<br>  styleUrls: [&#39;./dropdown-treeview.component.scss&#39;],<br>  encapsulation: ViewEncapsulation.None<br>})</pre><pre>export class DropDownTreeviewComponent {</pre><pre>@ViewChild(&#39;filter&#39;, {static: true})<br>targetElement: ElementRef;</pre><pre>@Input()<br>dropDownHeight = 300;<br>@Input()<br>treeData;<br>@Input()<br>selection: TreeNode;</pre><pre>@Output()<br>selectionChange = new EventEmitter();</pre><pre>visible: boolean = false;<br>id: any = Math.floor(Math.random() * 1000);</pre><pre>firstTimeLoad = true;<br>dropDownEl;</pre><pre>constructor() { }<br><br>click(event) {<br>  if(this.firstTimeLoad) {<br>   this.dropDownEl = document.getElementById(this.id);<br>   document.body.appendChild(this.dropDownEl);<br>   this.firstTimeLoad = false;<br>  }<br>  this.showDropDown();<br>}</pre><pre>setPosition() {<br>  const el: Element = this.targetElement.nativeElement;<br>  const position = el.getBoundingClientRect();<br>  this.dropDownEl.style.top = position.height + position.top + &#39;px&#39;;<br>  this.dropDownEl.style.left = position.left + &#39;px&#39;;<br>  this.dropDownEl.style.width = position.width + &#39;px&#39;;<br>  this.dropDownEl.style.height = this.dropDownHeight + &#39;px&#39;;<br>}</pre><pre> showDropDown() {<br>   this.visible = !this.visible;<br>   this.setPosition();<br> }<br> nodeSelect(event) {<br>   this.visible = false;<br>   this.selection = event.node;<br>   this.selectionChange.emit(event.node);<br> }</pre><pre>}</pre><p>Let me explain about the inputs and methods in the component.</p><p><strong>@Input dropDownHeight : </strong>This input is to set the height of the dropdown , Default height is 300 and it can be changed based on your wish by sending height as a input.</p><p><strong>@Input treedata: </strong>This input is used to get the hierarchical tree data from parent component.</p><p><strong>@Input selection</strong> : This input type is TreeNode and it is used to pass any selection by default from parent and it gets overridden on any tree node selection.</p><p><strong>@Output selectionChange</strong>: To emit the selected node to parent on any node selection.</p><p><strong>visible</strong>: Visibility of drop down drives by this class member.</p><p><strong>id: </strong>Every drop down needs a unique id and this class member got assigned with a random number.</p><p><strong>firstTimeLoad : </strong>This class member is used to set the position of drop down on first click later it was set to false.</p><p><strong>click</strong>: Click method gets invoked when user click on trigger or drop down. If it is first time, Based on id it fetches the element and attaches to the body and shows the drop down which has tree.</p><p><strong>setPosition</strong>: This method fetches the positions of input box and set positions to the drop down element.</p><p><strong>nodeSelect </strong>: This method will invoke on select of tree node and changes the visibility to hidden and updates the selectedNode class member to selected node. Latest changes gets emits using selectionChange event emitter.</p><p><strong>Here is the template and scss</strong></p><pre>&lt;div &gt;</pre><pre>&lt;div class=&#39;drop-down-tree-field&#39;&gt;</pre><pre>&lt;input #filter type=&quot;text&quot; (click)=&#39;click($event)&#39; class=&#39;col-12&#39; value={{selection?.label}} readonly&gt;</pre><pre>&lt;span class=&#39;pi pi-fw pi-caret-down drop-down-icon&#39;  (click)=&#39;click($event)&#39;&gt;&lt;/span&gt;</pre><pre>&lt;/div&gt;</pre><pre>&lt;div class=&quot;dropdown-section&quot;  [ngClass]=&#39;{&quot;hide&quot;: visible == false}&#39; [attr.id]=&#39;id&#39;&gt;</pre><pre>&lt;p-tree [value]=&quot;treeData&quot; selectionMode=&quot;single&quot; [(selection)]=&quot;selection&quot;  (onNodeSelect)=&quot;nodeSelect($event)&quot; [styleClass]=&quot;&#39;custom-ui-tree&#39;&quot;&gt; &lt;/p-tree&gt;</pre><pre>&lt;/div&gt;</pre><pre>&lt;/div&gt;</pre><p>scss file</p><pre>.drop-down-tree-field {</pre><pre>position: relative;</pre><pre>}</pre><pre>.dropdown-section {</pre><pre>position: absolute;</pre><pre>top: 50px;</pre><pre>left: 50px;</pre><pre>z-index: 1000;</pre><pre>float: left;</pre><pre>min-width: 10rem;</pre><pre>margin: .125rem 0 0;</pre><pre>font-size: 1rem;</pre><pre>color: #212529;</pre><pre>text-align: left;</pre><pre>list-style: none;</pre><pre>background-color: #fff;</pre><pre>background-clip: padding-box;</pre><pre>border-radius: .25rem;</pre><pre>overflow-y: auto;</pre><pre>overflow-x: none;</pre><pre>}</pre><pre>.hide {</pre><pre>display: none;</pre><pre>}</pre><pre>.drop-down-icon {</pre><pre>position: absolute;</pre><pre>right: 1%;</pre><pre>top: 20%;</pre><pre>}</pre><pre>.custom-ui-tree {</pre><pre>width: 100% !important;</pre><pre>height: 100%;</pre><pre>}</pre><p>The Position of drop down is absolute and the position of drop down changes based on the target and it is handled in component(set position method).</p><p>Please Note since we are using prime ng the respective css files should be declared in angular.json , Please check the snipped below.</p><pre>“styles”: [</pre><pre>“node_modules/primeicons/primeicons.css”,</pre><pre>“node_modules/primeng/resources/themes/nova-light/theme.css”,</pre><pre>“node_modules/primeng/resources/primeng.min.css”,</pre><pre>“src/styles.scss”</pre><pre>]</pre><p>Sample usage:</p><pre>&lt;dropdown-treeview [treeData]=’treeData’ [(selection)]=’selectedNode’ &gt;&lt;/dropdown-treeview&gt;</pre><p>Thank you any feedback on the blog is highly appreciated. :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=747800fed522" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>