Hi,
On my page I am rendering a grid. One of the columns is to a template column which loads images. The grid edit mode is set to Normal.
When I edit a row, the image in the template column goes away. If the edit mode is set to Batch, the image remains in view.
Is this default functionality of Grid? If so, is there a way to ensure that the image remains in view while editing the row?
|
@Html.EJS().Grid("FlatGrid").DataSource((IEnumerable<object>)ViewBag.dataSource).Width("auto").Height("359").Columns(col =>
{
col.HeaderText("Employee Image").Edit(new { create = "create", read = "read", destroy = "destroy", write = "write" }).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Template("#template").Width("150").Add();
col.Field("EmployeeID").HeaderText("Employee ID").Width("120").IsPrimaryKey(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("FirstName").HeaderText("Name").Width("125").Add();
col.Field("LastName").HeaderText("Title").Width("170").Add();
col.Field("BirthDate").HeaderText("Hire Date").Width("135").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add();
col.Field("Country").HeaderText("ReportsTo").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
}).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
</div>
<style>
.image img {
height: 55px;
width: 55px;
border-radius: 50px;
box-shadow: inset 0 0 1px #e0e0e0, inset 0 0 14px rgba(0, 0, 0, 0.2);
}
</style>
<script>
var elem;
var imgObject;
function create(args) {
imgObject = document.createElement('div');
imgObject.classList.add("image");
return imgObject;
}
function write(args) {
elem = document.createElement('img');
elem.src = "/Content/images/Employees/" + args.rowData.EmployeeID + ".png";
imgObject.appendChild(elem);
}
function destroy() {
imgObject.remove();
}
function read(args) {
return "";
}
</script> |
Thank you. This works perfectly