ag-grid设置成链接
时间: 2023-02-08 14:29:18 浏览: 80
要在ag-grid中设置链接,需要在列配置中设置链接单元格渲染器。可以使用"cellRenderer"属性来实现,如下所示:
```
var columnDefs = [
{headerName: "Name", field: "name", cellRenderer: linkCellRenderer},
// ...
];
function linkCellRenderer(params) {
return '<a href="' + params.value + '">' + params.value + '</a>';
}
```
在这个例子中,linkCellRenderer函数是一个自定义单元格渲染器,它接收一个参数对象,其中包含单元格的值。它返回一个HTML字符串,该字符串包含一个链接标签,其中链接的地址是单元格的值。
然后在gridOptions中设置columnDefs 即可
```
var gridOptions = {
columnDefs: columnDefs,
// ...
};
```
相关问题
ag-grid设置表格宽度
你可以使用 `gridWidth` 属性来设置表格的宽度。这个属性支持所有的CSS单位,例如像素(px)、百分比(%)、视窗宽度(vw)等等。
以下是一个示例:
```html
<ag-grid-angular
[gridOptions]="gridOptions"
[gridWidth]="800">
</ag-grid-angular>
```
在上面的示例中,表格的宽度被设置为 `800`,这意味着它将占据其父容器的800个单位。你可以根据需要调整这个值。
ag-grid-vue设置表格宽度
你可以通过设置 `width` 属性或者 `style` 属性来设置 ag-grid-vue 表格的宽度。
通过 `width` 属性设置表格宽度:
```html
<ag-grid-vue style="width: 100%;" :gridOptions="gridOptions" class="ag-theme-alpine"></ag-grid-vue>
```
通过 `style` 属性设置表格宽度:
```html
<ag-grid-vue :gridOptions="gridOptions" style="{width: '100%'}" class="ag-theme-alpine"></ag-grid-vue>
```
你可以把 `width` 或者 `style` 中的百分比值替换成任何你想要的宽度。
相关推荐
![js](https://img-home.csdnimg.cn/images/20210720083646.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)