Nativescript下拉插件仅显示Object对象,而不显示值

时间:2019-05-10 05:19:02

标签: nativescript nativescript-plugin

我正在尝试在下拉列表中显示对象值,并希望在选择任何值时获取整个对象值。我该如何设置?

我正在尝试使用“。”访问要显示的Object值。像下面这样的运算符

[["Kyle Freeland", "21"], ["Jon Gray", "55"], ["DJ Johnson", "63"]]

我要传递的数据如下

<dd:DropDown items="{{ raw_material_list.productName }}" selectedIndex="{{ raw_material_index }}" opened="dropDownOpened" closed="dropDownClosed" selectedIndexChanged="dropDownSelectedIndexChanged" class="dropDownStyle" />

我需要获得与我提到的完全相同的结果,欢迎任何帮助。

2 个答案:

答案 0 :(得分:0)

我已经更新了您的游乐场here

在drop-down-common.js中将library(plotly) plot_dendro(species.dend, height = 600, width=600) %>% hide_legend() %>% highlight(persistent = F, dynamic = F) 更改为display

productName

P.S。您必须使用ValueList.prototype.getDisplay = function (index) { if (types.isNullOrUndefined(index)) { return null; } if (index < 0 || index >= this.length) { return ""; } return this._array[index].productName; }; 作为对象。

答案 1 :(得分:0)

以上答案是正确的,但是对于这个问题,非常简单直接的解决方案是

var nativescript_drop_down_1 = require("../nativescript-drop-down") //Plugin

1> modify the array list like below

raw_material_list = new nativescript_drop_down_1.ValueList([
     {
       "id": "44",
       "created_date": "2019-04-19 12:01:13",
       "activeFlag": "true",
       "productType": "purchase",
       "productName": "suraksha",
     },
     {
       "id": "43",
       "created_date": "2019-04-19 11:59:59",
       "activeFlag": "true",
       "productType": "purchase",
       "productName": "vajra",
     }
   ]);

2>to access data 

let obj = viewModel.get("raw_material_list")._array[viewModel.get("raw_material_index")];

      console.log("----obj-----");
      console.log(obj);