agGrid Angular - add element (icon) on a row, column

守給你的承諾、 提交于 2021-01-05 12:27:59

问题


I'd like to know how can I add an icon to a row, something like in the picture below. I did my research on google, but found nothing helpful.

https://imgur.com/a/IU5JlbN "example"


回答1:


You should create a new field in your grid with Column def something like this -

{
    headerName: "",
    field: "icon",
    width: 100,
    cellRenderer: function(params) {
        return '<span><i class="fa fa-trash"></i></span>';
    }
}  

This will display an icon on the rightmost field.
However if you want your icon to respond to events or perform actions then you should look into implementing a cell Renderer component as described here.




回答2:


Go to your css then:

cellStyle: { 'justify-content': "flex-end" }

or

cellStyle: {textAlign: "right"}


来源:https://stackoverflow.com/questions/53327329/aggrid-angular-add-element-icon-on-a-row-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!