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. Image for the cookie policy date

ejDropDownList column datasource from ashx

Hi, 

Could you give a sample that use the ejGrid & ejDropDownList use Datasource from ashx





3 Replies

VN Vignesh Natarajan Syncfusion Team April 8, 2019 12:52 PM UTC

Hi Jeff, 

Thanks for contacting Syncfusion Support. 

Query: “Could you give a sample that use the ejGrid & ejDropDownList use Datasource from ashx 

From your query, we understand that you need to bind dataSource to Grid from ashx handler and perform CRUD action with dropdownlist in one of the column. We have used UrlAdaptor to bind dataSource from ashx page. Refer below link for the sample 


If your requirement is different from above solution, please share us the following details. 

  1. Do you need to bind different dataSource for dropdownList different from Grid data?
  2. Do you want to bind only dropdown dataSource alone from ashx page?
  3. Detail Explanation of exact scenario you need to achieve.
 
Requested details will be helpful for us to validate the reported query at our end. 
 
Regards, 
Vignesh Natarajan. 
 



JE jeff April 8, 2019 06:43 PM UTC

Hi,

I want to use the dropdownlist in ejgrid , dropdownlist datasource use the ashx to get json data, Could U give me the sample,
ejgrid datasource & dropdown list  are different datasource

Many Thanks


VN Vignesh Natarajan Syncfusion Team April 9, 2019 11:04 AM UTC

Hi Jeff,  
 
Query: “ Could U give me the sample,ejgrid datasource & dropdown list  are different datasource 
 
As per your requirement, we have prepared a sample by binding different dataSource to dropdownlist from ashx handler. Refer the below code example 
 
<script type="text/javascript"> 
        var ddldata; 
        $(function () { 
 
            // dataSource for Grid 
            var dataManager = ej.DataManager({ 
                url: "Handler/Data.ashx", 
                adaptor: new ej.UrlAdaptor() 
            }); 
 
            // dataSource for Dropdown element 
            var ddldataManager = ej.DataManager({ 
                url: "Handler/ddlData.ashx", 
                adaptor: new ej.UrlAdaptor() 
            }); 
 
            var query = ej.Query().take(5); 
            var execute = ddldataManager.executeQuery(query) // executing query 
                .done(function (e) { 
                    ddldata = e.result; // store the value from ashx in global variable 
                }); 
            var query = ej.Query().take(5); 
            var execute = dataManager.executeQuery(query) // executing query 
                .done(function (e) { 
 
                    // bind the dropdown dataSource from the global varibale 
                    $("#Grid").ejGrid({ 
                        dataSource: e.result, 
                        editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
                        toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
                        allowPaging: true, 
                        columns: [{ field: "OrderID", isPrimaryKey: true }, 
                        { field: "CustomerID" }, 
                        { field: "EmployeeID", editType: ej.Grid.EditingType.Dropdown, dataSource: ddldata, editParams: { fields: { text: "EmployeeID", value: "EmployeeID" }, enableDistinct: true } }, 
                        { field: "ShipCity" } 
                        ], 
                        ………………………………………………………………………… 
 
                    }); 
                }); 
 
 
        }); 
 
Note: in the dataManager done function we have stored the value in global variable and bind that dataSource to dropdownlist inside the Grid column using editParams.  
 
Refer the below screenshot for the output 
 
 
 
 
For your convenience we have attached the sample which can be downloaded from below link 
 
 
Run the sample.html by opening it in the visual studio. 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon