0

I am creating a syncfusion DropdownList which I want to populate with a json that I return from a controller of my Api, for this I have the following code in javascript:

   <input type="text" id="groupCodeList" />
var customerList = ej.DataManager({ url: "Administration/GetGroups", adaptor: new ej.UrlAdaptor(), crossDomain: true });

    $(function () {
            var groupCodeList = $('#groupCodeList').ejDropDownList({
                dataSource: customerList,
                fields: { text: 'ID', text: 'ProductName', value: 'ProductName' },
                itemsCount: 20,
                popupHeight: "200px",
                width: "250px",
                enableFilterSearch: true,
                enableServerFiltering: true,
                allowVirtualScrolling: true,
                search: function (args) {
                    if (args.searchString.length < 3) { //check search string length
                        args.cancel = true;
                    }
                }
            })
            //.data("ejDropDownList");
            //obj._updateSelectedIndexByValue = function () { }
        });

I then have a C# controller that receives the data as follows:

        public IActionResult GetGroups([FromBody] ExtendedDataManagerRequest dm)
        {
            var store = new Store();
            store.Result = new List<Product>();
            store.Count = 2;

            var p1 = new Product();
            p1.ProductName = "blabla";
            p1.ID = "1";
            var p2 = new Product();
            p2.ProductName = "popopo";
            p2.ID = "2";
            store.Result.Add(p1);
            store.Result.Add(p2);

            store.Result.ToArray();

            return Json(store);
        }

For some reason the dropdownlist never puts the values and it even seems to be disabled when I try to see if it has any value.

dropdwonlist disabled

I would also like to be able to send some extra parameter to the controller when the dropdown starts (this function is being fired when the page starts)

Any ideas? Thank you!

0 Answers0