cancel
Showing results for 
Search instead for 
Did you mean: 

Ui Component - import array

SOLVED

Ui Component - import array

Hi I would like to know how to import an array to a ui-select. With this code it does not display any options.


define([ 'jquery', 'underscore', 'uiRegistry', 'Magento_Ui/js/form/element/select', 'Magento_Ui/js/modal/modal', 'mage/url' ], function ($, _, uiRegistry, select, modal, url) { 'use strict'; return select.extend({ /** * On value change handler. * * @param {String} value */ onUpdate: function (value) { console.log('Selected Value: ' + value); // var field1 = uiRegistry.get('index = field1'); var field2 = uiRegistry.get('index = field2'); // // field2.hide(); // var field3Depend1 = uiRegistry.get('index = field3Depend1'); // console.log(require.toUrl('')); // console.log(field2.visibleValue); var linkUrl = url.build('customajax'); $.ajax({ url: '../../index/customajax', showLoader: true, data: {form_key: window.FORM_KEY, 'value':value}, type: "POST", dataType : 'json', success: function(data){ console.log(data.array); uiRegistry.get('index = attribute_item_value').options(data.array); } }); return this._super(); }, }); });
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Ui Component - import array

Hello @tvgarden

 

Try this if helps you:

https://alanstorm.com/magento-2-ui-component-data-sources/

Manish Mittal
https://www.manishmittal.com/

View solution in original post

2 REPLIES 2

Re: Ui Component - import array

Hello @tvgarden

 

Try this if helps you:

https://alanstorm.com/magento-2-ui-component-data-sources/

Manish Mittal
https://www.manishmittal.com/

Re: Ui Component - import array

@Manish Mittal Thank you for your reply.

 

I have read the page.

 

The problem was there was no 'Label' and 'Value' in the array.