2 mylogic mylogic 于 2016.04.21 10:30 提问

knockout级联绑定下拉框问题

网页中,如何利用Knockout.js把如下结构的json绑定到两个下拉框中,显示是CategoryName,value是CategoryId,父级变,子级下拉框跟着变,请大侠直接告诉我解决方案好吗?

 [
  {
    "ParentCategory": {
      "CategoryId": "a70b2eb0-483e-4bb7-a3da-4d80ab48d94f",
      "CategoryName": "类别A",

    },
    "SubCategoryList": [
      {
        "CategoryId": "2f8b3dbb-62c3-4955-8f4c-432d858164a0",
        "CategoryName": "A子类1",

      },
      {
        "CategoryId": "a94064c9-6176-4f22-8564-c59505f7b431",
        "CategoryName": "A子类2",

      },
      {
        "CategoryId": "b4b0b176-57a1-4f6c-9758-254eb3a30171",
        "CategoryName": "A子类3",

      }
    ]
  },
  {
    "ParentCategory": {
      "CategoryId": "05163221-d053-4469-86e2-5725fc00d759",
      "CategoryName": "类别B",

    },
    "SubCategoryList": [

    ]
  }
]

1个回答

hzaxxsrjzzttdwt
hzaxxsrjzzttdwt   2016.10.06 01:18

mvvmjsonknockout
网页中,如何利用Knockout.js把如下结构的json绑定到两个下拉框中,显示是CategoryName,value是CategoryId,父级变,子级下拉框跟着变,请大侠直接告诉我解决方案好吗?
[
{
"ParentCategory": {
"CategoryId": "a70b2eb0-483e-4bb7-a3da-4d80ab48d94f",
"CategoryName": "类别A",

},
"SubCategoryList": [
  {
    "CategoryId": "2f8b3dbb-62c3-4955-8f4c-432d858164a0",
    "CategoryName": "A子类1",

  },
  {
    "CategoryId": "a94064c9-6176-4f22-8564-c59505f7b431",
    "CategoryName": "A子类2",

  },
  {
    "CategoryId": "b4b0b176-57a1-4f6c-9758-254eb3a30171",
    "CategoryName": "A子类3",
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!