gallly
gallly

Reputation: 1211

Different ways to create ng-grid gridOptions?

An ng-grid uses gridOptions, which define what data to display. The api only shows simple examples such as

$scope.myData = [{name:'test'}];
var gridOption={data:'myData'}

It doesn't explain how to set data. If myData is an array of arrays instead

$scope.myData = [[{}],[{}]];
var gridOptions={data:'myData[0]'}; 

works and replacing 0 with 1 works. However, I can't seem to use a variable for the index?

I want to do

var gridOptions={data:'myData[index]'};

why doesn't this work and what are my options?

Upvotes: 0

Views: 113

Answers (1)

Ronnie
Ronnie

Reputation: 11198

The problem is 'myData[index]' isn't treated as a variable. It is seen as a string. What you would have to do is convert it to a string after the var is read like so 'myData[' + index + ']'

Upvotes: 1

Related Questions