在 中ag-grid,当我想检索我使用的行索引时:
params.node.id
Run Code Online (Sandbox Code Playgroud)
但是,我找不到对列执行相同操作的方法。我发现的只是检索columnId引用列定义中的字段变量。
即:如果这是列定义:
{
headerName: "checkButton 2",
field: "checkbuttonTwo",
cellRenderer: "checkButtonComponent",
width: 150
}
Run Code Online (Sandbox Code Playgroud)
这:
params.column.getId()
Run Code Online (Sandbox Code Playgroud)
将返回:
checkbuttonTwo
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:
有什么方法可以检索列索引吗?例如:对于第二列,我将有 2 等等。
谢谢
这是它的定义:
{
headerName: "Activité",
field: "activite",
editable: true,
, cellClass: "cell-wrap-text"
}
Run Code Online (Sandbox Code Playgroud)
这是每次用户在该列中输入新输入时我想启动的方法。
public UpdateActValue() {
this.data.sendActToBia(this.params.data.activite);
}
Run Code Online (Sandbox Code Playgroud)
以下是我的问题:
1/ 在编辑列中的单元格值后,是否有任何 ag-grid“本机”方式来启动特定方法?
2/ 我应该简单地定义一个自定义单元格渲染器并在那里完成所有必要的工作吗?
谢谢!
{
headerName: "Generic/Specific",
field: "genericspecific",
id: "6",
cellRenderer:'genericSpecificCellRenderersComponent',
cellStyle: params => {
const colors: string[] = ["red", "orange"];
const genericSpecific: string[] = ["Generic", "Specific"];
return {
"background-color": colors[genericSpecific.indexOf(this.selectedOptions[params.node.id])]
};
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,它有一个自定义的 Cell Renderer。这是它的定义:
@Component({
selector: "app-generic-specific-renderers",
template: `
<hr />
<select class="form-control" id='0' (change)="updateChosenValue($event.target); refresh(params)">
<option >{{ selectedOptions[params.node.id] }}</option>
<option >Specific</option>
<option >Generic</option>
</select>
<hr />
`
})
export class GenericSpecificCellRenderersComponent implements OnInit {
updateChosenValue(event) {
if (event.value==='Specific'){
this.selectedOptions[this.params.node.id]='Specific'
}
else if (event.value==='Generic'){
this.selectedOptions[this.params.node.id]='Generic'
}
}
selectedOptions:string[]=[];
constructor(private …Run Code Online (Sandbox Code Playgroud) 由于我不是前端开发人员并且我是从头开始构建 Web 应用程序,因此我下载了一个引导程序模板并尝试将其集成到一个简单的 Angular 项目(由 Angular CLI 生成)中。
我所做的是:
将模板的 index.html 文件复制到 app.component.html 中:
应用程序组件.html
<!DOCTYPE HTML>
<!--
Parallelism by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Parallelism by HTML5 UP</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<!-- Main -->
<section id="main">
<!-- Items -->
<div class="items">
<div …Run Code Online (Sandbox Code Playgroud)