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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change Template Values based on selected value in dropdown column

Thread ID:





132903 Sep 27,2017 09:53 PM UTC Sep 28,2017 12:31 PM UTC ASP.NET Web Forms 1
Tags: Grid
Ahmed Sherien
Asked On September 27, 2017 09:53 PM UTC

I've got a dropdown column with a display template:

<ej:Column Field="FactoryID" HeaderText="Factory" TextAlign="Center" Visible="true" AllowEditing="true"
           Template="<span class='label' style='min-width:70px;font-size:12px;cursor:pointer;color:white;background-color:{{:FactoryColor}} !important'>{{:FactoryName}}</span>"
           EditType="Dropdown" ForeignKeyField="FactoryID" ForeignKeyValue="FactoryName" />
I want the {{:FactoryName}} and {{:FactoryColor}} to be changed based on selected value not row value

Mani Sankar Durai [Syncfusion]
Replied On September 28, 2017 12:31 PM UTC

Hi Ahmed, 

Thanks for contacting Syncfusion support.  

We have analyzed your query and we found that you want to change the background color for the dropdown value based on selected data from dropdown and bind data for the foreign key column. Since {{:FactoryName}} and {{:FactoryColor}} is a field from the foreign key column so the data will not bound on template. But based on your requirement we can achieve it using templateRefresh property instead of binding it in direct template property. 

Refer the code example 
   <ej:Grid ID="FlatGrid" runat='server' AllowPaging="true"> 
            <ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Center" Visible="true" AllowEditing="true" 
           Template="<span class='label' style='min-width:70px;font-size:12px;cursor:pointer;color:white;'></span>" 
           EditType="Dropdown" ForeignKeyField="EmployeeID" ForeignKeyValue="FirstName" /> 
        <ClientSideEvents TemplateRefresh="refresh"/> 
        function refresh(args) { 
            var data = ej.DataManager(this.model.columns[2].dataSource).executeLocal(ej.Query().where("EmployeeID", "equal", parseInt(args.rowData.EmployeeID), true));   //data for the corresponding column will be filtered using where query from DataManager 
                 $(args.cell).find("span").css("background-color", data[0].Color);  
//set the background color for the template column 
                 $(args.cell).find("span").text(data[0].FirstName);  //set the value for the template 

We have also prepared a sample that can be available from the below link. 

Refer the documentation link. 

Please let us know if you need further assistance. 

Manisankar Durai. 


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