jQWidgets Forums

jQuery UI Widgets Forums Angular jqxgrid column button not firing event after adding icon over there

This topic contains 2 replies, has 2 voices, and was last updated by  shakti_singh 7 years, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • shakti_singh
    Participant

    Hello, I’m using jqxgrid component. I have a questions.
    I have added the buttons in grid. I want to attach an icon to the button instead of just text.
    However on adding icon , click event of the button is not firing . Please help !

    text: ”, datafield: ”, width: 90, cellsalign: ‘center’, columntype: ‘button’,
    buttonclick: (row: number): void => {
    alert(“Hi”);
    },
    cellsrenderer: () => {
    return ‘<span class=”glyphicon glyphicon-plus”></span>’;
    }
    `


    Stanislav
    Participant

    Hello shakti,

    Here is an example:
    app.component.ts

    
    import { Component, ViewEncapsulation  } from '@angular/core';
    
    @Component({
        selector: 'app-root',
        templateUrl: './app.component.html',
        styleUrls: ['./app.component.css'],
        encapsulation: ViewEncapsulation.None
    })
    
    export class AppComponent {
        source: any =
        {
            datatype: 'xml',
            datafields: [
                { name: 'ProductName', type: 'string' },
                { name: 'QuantityPerUnit', type: 'int' },
                { name: 'UnitPrice', type: 'float' },
                { name: 'UnitsInStock', type: 'float' },
                { name: 'Discontinued', type: 'bool' }
            ],
            root: 'Products',
            record: 'Product',
            id: 'ProductID',
            url: '../assets/sampledata/products.xml'
        };
    
        dataAdapter: any = new jqx.dataAdapter(this.source);
    
        columns: any[] =
        [
            { text: 'Product Name', columngroup: 'ProductDetails', datafield: 'ProductName', width: 250 },
            { text: 'Quantity per Unit', columngroup: 'ProductDetails', datafield: 'QuantityPerUnit', cellsalign: 'right', align: 'right' },
            { text: 'Unit Price', columngroup: 'ProductDetails', datafield: 'UnitPrice', align: 'right', cellsalign: 'right', cellsformat: 'c2' },
            { text: 'Units In Stock', datafield: 'UnitsInStock', cellsalign: 'right', width: 100 },
            { text: 'Discontinued', columntype: 'checkbox', datafield: 'Discontinued', align: 'center' },
            {
                text: '', datafield: '', width: 90, cellsalign: 'center', columntype: 'button',
                cellsrenderer: () => {
                    return '<span  class="<span class="glyphicon glyphicon-plus"></span>';
                },
                buttonclick: (row: number): void => {
                    alert("Hi");
                }
            }
        ];
    }
    

    app.component.css

    
    .jqx-grid-cell input[type="button"] {
        width: 100%;
        opacity: 0.01 !important;
        z-index: 9999 !important;
        display: block !important;
    }
    

    Best Regards,
    Stanislav

    jQWidgets Team
    http://www.jqwidgets.com/


    shakti_singh
    Participant

    Hi Stanislav!

    Thank you 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.