angular-ui/ui-grid

Update "Binding examples" documentation to demonstrate binding to 2D array

已關閉

#4,244 建立於 2015年8月22日

 (1 則留言) (0 個反應) (0 位負責人)JavaScript (2,496 個分叉)batch import
good first issuetype: docs

倉庫指標

星標
 (5,395 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Update the "Binding examples" documentation to demonstrate how to bind the grid to a 2D array as opposed to an array of objects/entities. It wasn't clear how to do this, and I don't know if this is an intentional feature or just a result of doing "row.entity[{field}]" on the field expression, but it seems to work.

// Data is 2D array
var data = [
    ["Cox", "Carney", "Enormo", true],
    ["Lorraine", "Carney", "Comveyer", false],
    ["Nancy", "Waters", "Fuelton", false]
  ];

// Field expression is index of field within row array
var colDefs = [
    { name: "firstName", field: "0" },
    { name: "lastName", field: "1" },
    { name: "company", field: "2" },
    { name: "employed", field: "3" },
  ];

$scope.gridOptions = {
    data: data,
    columnDefs: colDefs
  };

貢獻者指南