|
$(function () {
$("#Grid").ejGrid({
...
actionComplete: "complete",
columns: [
...
]
});
});
function complete(args) {
if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "dialog") {
var row = this.model.selectedRowIndex;
var target = this.getRowByIndex(row);
var $target = $(target);
var docWidth = $(document).width(), dlgWidth = document.documentElement.clientWidth < 800 ? 200 : 250,
xPos = $target.position().left + 18,
yPos = $target.position().top + 2;
$("#" + this._id +"_dialogEdit").ejDialog({ //this._id is the ID of grid
title: args.requestType == "beginedit" ? "Edit" : "Add",
enableResize: true, //enable resize to dialog
position: { X: xPos, Y: yPos },
});
}
} |
|
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
allowPaging: true,
actionComplete: "complete",
. . .
});
});
function complete(args) {
if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "dialog") {
$("#Grid_dialogEdit").ejDialog({
open: ej.proxy(function (args) {
if (args.requestType == "beginedit") {
var top = $('#Grid td.e-active').first().parent().offset().top - 200;
if (top < 50) top = 100;
$('#Grid_dialogEdit_wrapper').css('top', top);
$('html, body').animate({ scrollTop: top }, 0);
}
}, this, args)
});
}
}
</script> |