|
<ejs-grid id="Grid" dataSource="ViewBag.dataSource" width="auto" queryCellInfo="queryCellInfo" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })">
<e-grid-columns>
<e-grid-column foreignKeyField="UploadFiles" template="#template" dataSource="ViewBag.dataSource" headerText="Employee Image" textAlign="Center" width="150"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script id="template" type="text/x-template">
${if(UploadFiles.length > 0)}
<button id="element">Edit</button>
${else}
<input type="file" id="fileupload" name="UploadFiles">
${/if}
</script>
<script>
function queryCellInfo(args) {
var btnele = args.cell.querySelector('button');
var button = new ej.buttons.Button({ cssClass: `e-flat`, iconCss: 'e-edit e-icons' }, btnele);
// based on condition we have rendered uploader control
var ele = args.cell.querySelector('input');
var uploadObject = new ej.inputs.Uploader({
. . . . .
});
uploadObject.appendTo(ele);
}
</script> |