We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Inline dropdownlist in a datagrid - bind data source

Thread ID:

Created:

Updated:

Platform:

Replies:

145839 Jul 10,2019 09:40 AM UTC Jul 15,2019 05:29 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: DataGrid
Sanjay
Asked On July 10, 2019 09:40 AM UTC

Hi


Have defined a dropdownlist

 
        var itemCodeFilterDropDownList = new DropDownList
        {            
            AllowFiltering = true,
            Id = "saleItemFilterCodeDropDown",
            Filtering = "onFilteringItemCode",
            Placeholder = "Select",
            ActionBegin = "addQuery"
        };


This is part of inline editor in a datagrid

 <e-grid-column field="ItemCode" headerText="Code" width="150" validationRules="@(new {required = true})" headerTextAlign="Left" textAlign="Left" editType="dropdownedit" id="dropDownEditFilter" 
                           edit="@(new {@params = itemCodeFilterDropDownList})">
 </e-grid-column>


During edit mode on entry of 2 or characters want to look up the item.

function onFilteringItemCode(ex) {

    if (ex.text !== '' && ex.text.length >= 2)
    {

        var item = document.getElementById("saleItemFilterCodeDropDown");

        var dataManager = new ej.data.DataManager({ url: "/Sale/ProductList", adaptor: new ej.data.UrlAdaptor })
            .executeQuery(new ej.data.Query().where('ItemCode', 'startswith', e.text))
            .then((e) => {
                item.dataSource = e.result;
               
            });     
    }
}

The issue is "item" is null. How do I get access to the dropdownlist element and update the datasource.

Thanks
Sanjay


Thavasianand Sankaranarayanan [Syncfusion]
Replied On July 11, 2019 07:27 AM UTC

Hi Sanjay, 

Thanks for contacting Syncfusion support. 

From your code we, found that you have incorrectly taken the instance for the dropDownList. So, please change the instance code like as below code snippet to access all the properties of the dropDownList inside the dataManager “then” function, 

  function onFilteringItemCode(ex) { 
        if (ex.text !== '' && ex.text.length >= 2) { 
            var item = this; // DropDownList instance 
            var dataManager = new ej.data.DataManager({ url: "/Sale/ProductList", adaptor: new ej.data.UrlAdaptor }) 
                .executeQuery(new ej.data.Query().where('ItemCode', 'startswith', e.text)) 
                .then((e) => { 
                    item.dataSource = e.result; 
                }); 
        } 
    } 

Regards, 
Thavasianand S. 


Sanjay
Replied On July 14, 2019 05:28 AM UTC

Thank you very much.

This is now working.

Thanks again
Sanjay

Thavasianand Sankaranarayanan [Syncfusion]
Replied On July 15, 2019 05:29 AM UTC

Hi Sanjay, 
 
Thanks for your update. 
 
We are happy that the problem has been resolved at your end. 
 
Regards, 
Thavasianand S.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon