0

我有一个多维数组,其中有“地区”“国家”“州”列,我为所有这些创建了下拉列表。现在我想将这些下拉列表的初始状态设置为第二行的值。我正在尝试编写一个 javascript 函数,该函数从数组中检索值并将初始状态设置为该值。请在下面找到我的代码来为“区域”创建一个控件包装器。我想把 javascript 函数放在这个控件包装器中。请建议

     var regionPicker = new google.visualization.ControlWrapper({
    'controlType': 'CategoryFilter',
    'containerId': 'control1',
    'options': {
        'filterColumnLabel': 'Region',
        'ui': {
            'labelStacking': 'vertical',
            'allowTyping': false,
            'allowMultiple': false,

        }
    }

    });

谢谢

4

1 回答 1

0

如果您知道要从中提取默认值的 DataTable 中的行和列,那么解决方案很简单:

// data is your DataTable object
// regionColumn is the index of the "Region" column in the DataTable
// defaultRow is the row in the DataTable that you want to pull your default values from
var regionPicker = new google.visualization.ControlWrapper({
    'controlType': 'CategoryFilter',
    'containerId': 'control1',
    'options': {
        'filterColumnLabel': 'Region',
        'ui': {
            'labelStacking': 'vertical',
            'allowTyping': false,
            'allowMultiple': false
        }
    },
    state: {
        selectedValues: [data.getValue(defaultRow, regionColumn)]
    }
});
于 2013-08-14T15:06:52.757 回答