I how to display grid based on condition with chec

2019-08-07 10:27发布

In html page i am displaying the drop down ,the item in the drop down are dynamic ,and below the drop down displaying the ng-grid data with check boxes these are also dynamic ,the dynamic drop down has the j son data as

[
  {
    "c": "D",
    "l": 1,
    "cId": 1
  },
  {
    "c": "J",
    "l": 2,
    "cId": 3
  },
  {
    "c": "G",
    "l": 3,
    "cId": 1
  }
]

In drop down i have displayed only property "c" value . The dynamic grid had dynamic j son data as

 [
  {
    "c": "U t",
    "cC": "Ut",
    "cId": 1
  },
  {
    "c": "Ca",
    "cC": "CA",
    "cId": 2
  },
  {
    "c": "U i",
    "cC": "MN",
    "cId": 3
  }
{
    "c": "U i",
    "cC": "MN",
    "cId": 4
  }
{
    "c": "U p",
    "cC": "Mz",
    "cId": 5
  }
{
    "c": "U r",
    "cC": "Mc",
    "cId": 6
  }
{
    "c": "U h",
    "cC": "Mj",
    "cId": 7
  }




]

In grid i am showing only property of vlaue "c": If i select "c": "J" in drop down then if the "cId": 3 matched with cid of

"c": "U i",
"cC": "MN",
 "cId": 3 

whose data in grid then display that grid with check box selected with thick select mark ,and also if the unselected items in the drop down cId's are match with grid then display the grid with check box selected with light select mark .

After submit the button below the grid then display the only thick selected items of property value "c":

any thoughts on how to do this and/or a code plunkers would be greatly appreciate. Thanks!

LIght tick mark for unselected drop down id's match with grid ids

Item 1 selected result

enter image description here

1条回答
Animai°情兽
2楼-- · 2019-08-07 11:11

so you need to specify primaryKey field in gridOptions...

$scope.myData = [{name: "Moroni", age: 50, id: 101},
                 {name: "Tiancum", age: 43, id: 102},
                 {name: "Jacob", age: 27, id: 103},
                 {name: "Nephi", age: 29, id: 104},
                 {name: "Enos", age: 34, id: 105}];
$scope.gridOptions ={
    data: 'myData',
    primaryKey: 'id'
}
查看更多
登录 后发表回答