<script src="Scripts/jquery-2.1.4.js"></script>
<style type="text/css">
.dhxform_obj_dhx_skyblue {
font-family: Arial !important;
}
.LabelHeader {
color: black !important;
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue .dhxform_textarea {
/*border: 0px !important;*/
/*background-color: transparent !important;*/
/*font-size: 8pt !important;*/
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue div.dhxform_txt_label2 {
color: black;
font-weight: normal;
/*font-size: 8pt !important;*/
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue fieldset.dhxform_fs legend.fs_legend {
color: black !important;
font-weight: normal !important;
/*font-size: 8pt !important;*/
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue fieldset.dhxform_fs {
border: 1px solid gray !important;
}
</style>
<script type="text/javascript">
var myForm, formData;
var success, fail;
var tempRole; var noAccessRight; var tempDays;
var mygrid;
$(document).ready(function () {
doOnLoad();
});
var box = null;
function doOnLoad() {
formData = [
{ type: "newcolumn", offset: 5 },
{ type: "button", name: "Save", value: "Save", offsetLeft: 0, offsetTop: 0, width: "70" }
];
form_container = new dhtmlXForm("form_container", formData);
form_container.setFontSize("8pt");
form_container.attachEvent("onButtonClick", function (id) {
if (id == "Save") {
box = dhtmlx.modalbox({
text: "Loading, Please Wait...",
width: "300px"
});
var count = mygrid.getRowsNum();
if (count > 0) {
var state = mygrid.getStateOfView();
for (var idx = state[1]; idx < state[2]; idx++) {
var listArguments = new Array();
for (i = 0; i <= 2 ; i++) {
listArguments[i] = mygrid.cells(idx + 1, i).getValue();
}
ExecuteSave(getRequestData(listArguments));
}
if (fail > 0) {
dhtmlx.modalbox.hide(box);
dhtmlx.message({
title: "Save",
type: "alert",
text: "Save failed. Please retry!",
callback: function () { }
});
}
else if (success > 0) {
debugger;
dhtmlx.modalbox.hide(box);
dhtmlx.message({
title: "Save",
type: "alert",
text: "Save successful!",
callback: function () {
debugger;
mygrid.clearAll();
ReloadGrid();
}
});
}
} else {
dhtmlx.modalbox.hide(box);
dhtmlx.message({
title: "Save",
type: "alert",
text: "No Record!",
callback: function () {
debugger;
}
});
}
}
})
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setSkin("dhx_skyblue");
mygrid.setImagePath("imgs/");
mygrid.setHeader(",ROLE CODE,ROLE NAME");
mygrid.setInitWidthsP("20,30,*");
mygrid.setColTypes("link,ro,ro");
mygrid.setStyle("font-family:arial;font-size:8pt;font-weight:bold", "font-family:arial;font-size:8pt;", "font-family:arial;font-size:8pt;", "font-family:arial;font-size:8pt;");
mygrid.enablePaging(true, 31, 5, "pagingbox");
mygrid.init();
mygrid.attachEvent("onXLS", function () {
box = dhtmlx.modalbox({
text: "Loading, Please Wait...",
width: "300px"
});
});
mygrid.attachEvent("onXLE", function (value, text) {
dhtmlx.modalbox.hide(box);
});
document.getElementById("gridbox").style.height = document.body.offsetHeight - 55 + "px";
ReloadGrid();
}
function getRequestData(data) {
return JSON.stringify({
"filterExpression": data
});
}
function ReloadGrid() {
mygrid.clearAll();
mygrid.load("Handler1.ashx/?type=RoleGridData",
function () { //loading data to the grid
}, "json");
}
var success, fail;
function ExecuteSave(methodArguments) {
success = 0, fail = 0;
$.ajax({
type: "POST",
async: false,
url: "WebFormSaveGridWithLoadingPanel.aspx" + "/" + "SaveTransaction",
data: methodArguments,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: alertSuccess,
fail: alertFail
});
}
function alertSuccess(result) {
//alert(result);
success++;
}
function alertFail(result) {
//alert(result);
fail++;
}
</script>
<div id="form_container" style="height: 32px"></div>
<div>
<table style="width: 100%">
<tr>
<td>
<div id="gridbox" style="width: 100%; height: 400px;"></div>
</td>
</tr>
<tr>
<td>
<div id="pagingbox"></div>
</td>
</tr>
</table>
</div>