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

Grid Dialog - ejDropDownList get selected code

Hi


How to get  ejDropDownList get selected code  in code behind 


  if ((args.requestType == "beginedit" || args.requestType == "add")) {

   $("#ShipCountry").ejDropDownList({ width: '116px', dataSource: args.model.columns[0].dataSource, fields: { text: "Text", value: "Text", id: "Id" } });

}

  if (args.requestType == "beginedit") {

     $("#ShipCountry").ejDropDownList("setSelectedValue", args.row.children().eq(4).text());
}

 protected void EditAction(string eventType, object record)
    {

            can i get select ejDropDownList selected Id  
  
    }

Pratheep

Attachment: dropdownlist_1ac941e5.rar

3 Replies

RU Ragavee U S Syncfusion Team July 4, 2016 09:07 AM UTC

Hi Pratheep, 

Based on your requirement, we have modified your sample to obtain “Id” value of the item selected in dropdownlist at the server side, which can be downloaded from the below location. 


In the above sample, we have dynamically triggered the “endEdit” event of the Grid by passing the required parameters to the server side. Please refer to the below code example. 

function begin(args) { 
                    if(args.requestType == "save"){ 
                        var dropData = $("#ShipCountry").ejDropDownList("instance"); 
                        dropDownModel = dropData.getItemDataByValue(dropData.getSelectedValue())[0].Id; //get the Id of the selected Item 
                        } 
                } 
 
function endEdit(args) { 
            flag++; 
            if (args.dropDownModel == undefined) { 
                if (flag == 1) 
                    triggerEvent(args); 
                flag = 0; 
                return false 
            } 
             
        } 
        function triggerEvent(e) { 
            var obj = $("#OrdersGrid").data("ejGrid"); 
            var args = { data: e.data, previousData: e.previousData, foreignKeyData: e.foreignKeyData, dropDownModel: dropDownModel };//pass the Id value as event argument 
            obj._trigger("endEdit", args); 
        } 
 
protected void EditEvents_ServerEditRow(object sender, GridEventArgs e) 
        { 
            var dropDataModel = e.Arguments["dropDownModel"];//returns the id of the selected dropdownlist item 
            EditAction(e.EventType, e.Arguments["data"]); 
        } 

Regards, 
Ragavee U S. 



PR Pratheep July 5, 2016 05:30 AM UTC

Hi

Working fine, Thanks

Pratheep


PK Prasanna Kumar Viswanathan Syncfusion Team July 6, 2016 04:09 AM UTC

Hi Pratheep,
 
We are happy that the provided solution working fine at your end.
 
Regards,
 
Prasanna Kumar N.S.V

Loader.
Up arrow icon