javascript - Displaying elements within an array of strings using ng-grid? -


i have simple json array of strings in want display on ng-grid. example, if have array looks so:

arrayofstrings: ["test", "blah", "foo"]; 

i want list elements within array in column in ng-grid, having trouble doing so. here how tried render elements within array:

{field: 'arrayofstrings', displayname: 'array', width:'20%',     celltemplate: '<div class="ngcelltext" ng-class="col.colindex()"><span ng-cell-text>{{row.getproperty(col.field)}} </span></div>'}, 

however, nothing shows up. if knows how display elements within array column, appreciated. thanks!

i think you're asking how display of items in array within same column. let me know if that's not case , i'll edit answer. if field contains array of strings, ng-grid default display string representation of whole array:

["test", "blah", "foo"] 

you can add cellfilter on column

{field: 'arr', displayname: 'arrayofstrings', cellfilter: 'stringarrayfilter'} 

to control how array data represented:

filter('stringarrayfilter', function() {   return function(myarray) {     return myarray.join(', ');   }; }) 

see example plunker here.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -