...
<ejs-grid id="Grid" actionBegin="actionBegin" toolbar="@(new List<string>() { "Add", "Update", "Cancel" })" created="created">
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true">
</e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="orderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="customerID" width="140"></e-grid-column>
<e-grid-column field="shipCity" headerText="ship City" template="#columnTemplate" edit="@(new {create = "create", read = "read", write = "write"})" width="200">
</e-grid-column>
</e-grid-columns>
</ejs-grid>
<script type="text/x-template" id="columnTemplate">
<img src='/images1000.png' />
</script>
<script type="text/javascript">
var dataSource = @Html.Raw(Json.Serialize(ViewBag.datasource));
function created(args) {
this.dataSource = new ej.data.DataManager({
json: dataSource,
insertUrl: 'Home/NormalInsert',
adaptor: new ej.data.RemoteSaveAdaptor()
});
}
var elem;
var dobj;
function create() {
elem = document.createElement('div');
return elem;
}
function write(args) {
$(elem).ejSignature({ width: "200px", height: "35px", backgroundcolor: "yellow" });
}
function read(args) {
return $(elem).ejSignature({});
}
function actionBegin(args) {
if (args.requestType == "save" || args.requestType == "cancel") {
var canvas = $("#Grid").find("canvas")[0];
image = canvas.toDataURL("image/png");
var imgData = image.replace('data:image/png;base64,', '');
args.data.shipCity = imgData;
}
}
... |