Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取ui网格中列的索引_Javascript_Angularjs_Angular Ui Grid - Fatal编程技术网

Javascript 获取ui网格中列的索引

Javascript 获取ui网格中列的索引,javascript,angularjs,angular-ui-grid,Javascript,Angularjs,Angular Ui Grid,我正在尝试创建一个自定义列菜单项,它将获取列中的所有行,确定这些数字的范围,并确定该范围内该行的百分比-以从红色到绿色的比例分配颜色。我有着色算法和函数,从我以前做这件事开始,但在我没有使用angular之前,我使用了。现在我需要能够使用列的菜单来启动此功能 我只需要确定打开菜单的列的索引,以便函数知道要选择哪个列,并使用:nth childindex jquery/CSS psuedoclass选择器更改CSS 我的angular设置和此功能如下:您能在问题部分包含相关代码吗?如果外部站点关闭

我正在尝试创建一个自定义列菜单项,它将获取列中的所有行,确定这些数字的范围,并确定该范围内该行的百分比-以从红色到绿色的比例分配颜色。我有着色算法和函数,从我以前做这件事开始,但在我没有使用angular之前,我使用了。现在我需要能够使用列的菜单来启动此功能

我只需要确定打开菜单的列的索引,以便函数知道要选择哪个列,并使用:nth childindex jquery/CSS psuedoclass选择器更改CSS


我的angular设置和此功能如下:

您能在问题部分包含相关代码吗?如果外部站点关闭,问题似乎不完整。他们关于列菜单自定义的文档似乎有一个线索:具体来说,this.context.col应该返回单击的列对象。我没有看到索引属性,但希望这能为您指明正确的方向。@nairys让我走得够远了-我注销了this.context.col,然后找到this.context.col.colDef.name,并遍历$scope.columnDefs数组,找到名称与之相等的索引。好主意,谢谢.NP-希望您没有同名的列。很高兴这有帮助。@J-Dizzle不是从名称中获取索引,而是:使用indexOf在数组$scope.columnDefs中搜索this.context.col以获得索引,这将解决具有相同显示名称的多个列的问题