Many thanx! Now it works correctly!
Upper screenshot taken when after page loading I try to delete 3rd row “Deletable”.
Lower screenshot taken when after page loading I try to delete 1st or 2nd row “UnDeletable” and then 3rd.
<!DOCTYPE html>
<html lang=”en-us”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″/>
<meta charset=”utf-8″ />
<title>TEST</title>
<script src=”/Scripts/jquery-2.1.4.js”></script>
<script src=”/Scripts/jquery-ui-1.11.4.js”></script>
<script src=”/Scripts/trirand/i18n/grid.locale-en.js”></script>
<script src=”/Scripts/trirand/jquery.jqGrid.min.js”></script>
<script src=”/Scripts/jquery.global.js”></script>
<link href=”/Content/themes/hot-sneaks/jquery-ui.css” rel=”stylesheet”/>
<link href=”/Content/themes/ui.jqgrid.css” rel=”stylesheet”/>
</head>
<body>
<form >
<table>
<tr>
<td ><table id=’grid’></table>
</tr>
</table>
</form>
</body>
</html>
<script>
$(document).ready(function () {
var data = [
{ “id”: “1”, Title: “Non deletable”, “used”: “+” },
{ “id”: “2”, Title: “Non deletable”, “used”: “+” },
{ “id”: “3”, Title: “Deletable”, “used”: “-” }];
$(‘#grid’).jqGrid({
data: data,
datatype: “local”,
page: 1,
colNames: [“id”, “Title”, “used”],
colModel: [
{
“searchoptions”: {
“searchhidden”: true
},
“index”: “id”,
“hidden”: true,
“key”: true,
“name”: “id”
},
{
“editoptions”: {
“title”: “Title”
},
“width”: 50,
“align”: “center”,
“name”: “Title”,
“index”: “Title”,
“editable”: true
},
{
“search”: false,
“width”: 50,
“index”: “used”,
“align”: “center”,
“name”: “used”
}],
viewrecords: true,
scrollrows: false,
prmNames: { id: “id” },
headertitles: true,
hoverrows: false,
pager: “#grid_pager”,
rowNum: 10,
rowList: [10],
editDialogOptions: {
“recreateForm”: true,
“closeAfterEdit”: true,
“modal”: true,
},
addDialogOptions: {
“closeAfterAdd”: true,
“recreateForm”: true,
“modal”: true,
},
delDialogOptions: {
“modal”: true,
“recreateForm”: true,
},
searchDialogOptions: {
“resize”: false,
“recreateForm”: true
},
viewRowDialogOptions: {},
jsonReader: { id: “id” },
sortname: ‘id’,
sortorder: ‘asc’,
caption: ‘ ‘,
width: ‘400’,
height: ‘100%’,
viewsortcols: [false, ‘vertical’, true]
});
var grid = $(‘#grid’);
var edopt = grid.getGridParam(‘editDialogOptions’);
var addopt = grid.getGridParam(‘addDialogOptions’);
var delopt = grid.getGridParam(‘delDialogOptions’);
var viewopt = grid.getGridParam(‘viewRowDialogOptions’);
var searchopt = grid.getGridParam(‘searchDialogOptions’);
delopt.beforeInitData = BeforeDel;
jQuery(‘#grid’).navGrid(‘#grid_pager’, {
“edit”: false,
“add”: false,
“del”: true,
“search”: false,
“refresh”: false,
“view”: false,
“position”: “left”,
“cloneToTop”: true
},
edopt, addopt, delopt, searchopt, viewopt);
});
function BeforeDel(form) {
var rowid = $(‘#grid’).jqGrid(‘getGridParam’, ‘selrow’);
var rowData = $(‘#grid’).getRowData(rowid);
if (rowData.used == ‘+’) { alert(‘Error’); return false; }
else { return true; }
}
</script>
It’s , it seems unlikely, icons are absent only when first call of beforeInitData returns false. In anoter case buttons are correct.
I’ll try to reduce code to minimum and write it.
Thank you, but some problem remains. Delete Dialog shown now, but buttons Cancel & OK are without icons and not work.
Excuse, link was truncated.
This is truncated part:
?page_id=393/bugs/returning-false-from-beforeinitdata-callback-causes-a-bug
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top