I how to display grid based on condition with checked selected (tick mark)

我与影子孤独终老i 提交于 2020-01-06 04:28:11

问题


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!


回答1:


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'
}


来源:https://stackoverflow.com/questions/24991240/i-how-to-display-grid-based-on-condition-with-checked-selected-tick-mark

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!