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">
...
<Columns>
...
<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" />
...
</Columns>
<ClientSideEvents TemplateRefresh="refresh"/>
</ej:Grid>
<script>
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
}
</script> |
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.
Regards,
Manisankar Durai.