Hi Tony,
The problem has been fixed. Thank you very much for the quick response to resolving this issue.
Regards,
Marv
Tony,
The whole point of reporting this issue wasn’t that I could not find a fix, but that the behavior of jqGrid v5.0.0 changed from v4.8.2.
If you return to thecybersafe.net you will see that I have two identical versions of this page — one referencing v5.0.0 and the other v4.8.2, with a button on each page to flip back and forth.
The v5.0.0 page clicks the ‘Show Data’ button when you hit enter on the inline edit selected line after you change the description and the v4.8.2 does not.
Applying the fix you mentioned could be a problem since I have hundreds of pages that may or may not have form submit requirements.
Thanks,
Marv
Hi Tony,
I agree that the page you gave me works okay — why yours works and mine does not I do not know. Here is a link to a totally standalone HTML file that on Windows 10, 8.1 and 7 — any browers — does not work for me.
By the way, after you change the Region description press the Enter key. I get the JSON display of the data object — not the saving of the edited row.
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”InlineEditStandalone.aspx.cs” Inherits=”InlineEditStandalone” %>
<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″ />
<title>jqGrid Inline Edit Test</title>
<!– cupertino, redmond, hot-sneaks, start, ui-darkness, mint-choc, smoothness –>
<link type=”text/css” rel=”stylesheet” href=”//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/hot-sneaks/jquery-ui.css” />
<link type=”text/css” rel=”stylesheet” href=”jqGrid/ui.jqgrid.5.0.0.css” />
<style type=”text/css”>
body {
font-family: Arial;
}
.ui-widget {
font-size: 0.8em;
}
.ui-jqrid {
font-family: 0.8em;
}
.ui-widget-overlay {
opacity: 0.4 !important;
background: inherit;
background-color: #aaa;
}
</style>
</head>
<body>
<form id=”form1″ runat=”server”>
<asp:ScriptManager ID=”scriptManager” runat=”server” EnablePageMethods=”true” EnablePartialRendering=”false”>
<Scripts>
<asp:ScriptReference Path=”//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js” />
<asp:ScriptReference Path=”//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js” />
<asp:ScriptReference Path=”~/jqGrid/i18n/grid.locale-en.5.0.0.js” />
<asp:ScriptReference Path=”~/jqGrid/jquery.jqGrid.5.0.0.min.js” />
</Scripts>
</asp:ScriptManager>
<table id=”dgRegions”></table>
<table id=”pgRegions”></table>
<button id=”btnShowData” style=”display: none;”>Show Data</button>
<script type=”text/javascript”>
var data = {};
var lastSel;
function cancelEditing(myGrid) {
if (lastSel != null) {
$(myGrid).jqGrid(‘restoreRow’, lastSel);
var lrid = $.jgrid.jqID(lastSel);
$(“tr#” + lrid + ” div.ui-inline-edit, ” + “tr#” + lrid + ” div.ui-inline-del”).show();
$(“tr#” + lrid + ” div.ui-inline-save, ” + “tr#” + lrid + ” div.ui-inline-cancel”).hide();
}
}
function LoadGrid(data) {
if ($(‘#dgRegions’)[0].grid) {
$(‘#dgRegions’).jqGrid(‘GridUnload’);
}
var dgRegions = $(‘#dgRegions’).jqGrid({
datatype: ‘local’,
data: data.rows,
cmTemplate: {
searchoptions: { sopt: [‘bw’, ‘cn’, ‘nc’, ‘eq’, ‘ne’, ‘lt’, ‘le’, ‘gt’, ‘ge’, ‘bn’, ‘in’, ‘ni’, ‘ew’, ‘en’] }
},
colModel: [
{ name: ‘RegionID’, hidden: true, key: true },
{
label: ‘Region’, name: ‘RegionDescription’, index: ‘RegionDescription’, editable: true, editoptions: { size: 40, maxlength: 50 }, editrules: {
custom: true,
custom_func: function (value, label) {
if (value.trim().length === 0)
return [false, $.validator.format(‘{0}: Field is required’, label)];
else if (value.substr(0, 1) === ‘ ‘)
return [false, $.validator.format(‘{0}: Field cannot begin with space’, label)];
else
return [true, ”];
}
}
},
{
label: ‘ ‘, formatter: ‘actions’, width: 60, fixed: true, search: false,
formatoptions: {
url: ‘clientArray’,
keys: true,
delbutton: false,
onEdit: function (rowid) {
if (lastSel != null && rowid !== lastSel) {
cancelEditing($(this));
}
lastSel = rowid;
},
afterSave: function (rowid) {
var row = $(this).getRowData(rowid);
$.each(data.rows, function (i, drow) {
if (drow.RegionID === row.RegionID) {
drow.RegionDescription = row.RegionDescription;
return false;
}
});
}
}
}
],
caption: ‘R e g i o n s’,
pager: ‘#pgRegions’,
sortname: ‘RegionDescription’,
sortorder: ‘asc’,
width: 500,
height: ‘100%’,
pginput: true,
pgbuttons: true,
rowNum: 15,
rowList: [10, 15, 20, 25],
viewrecords: true,
shrinkToFit: true,
onSelectRow: function (rowid) {
if (lastSel != null && rowid !== lastSel) {
cancelEditing(this);
}
lastSel = rowid;
}
});
dgRegions
.jqGrid(‘filterToolbar’, {
searchOperators: true,
stringResult: true
})
.jqGrid(‘navGrid’, ‘#pgRegions’, { search: false, refresh: false, edit: false },
{ width: 400 },
{ width: 400 },
{ width: 400 }
);
}
$().ready(function () {
/* jqGrid 5.0.0 introduced a change that propagated the Enter key up the DOM outside the grid — code below cancels this behavior */
//$(document).on(‘keydown’, ‘.ui-jqgrid .editable’, function (e, ui) {
// if (e.which === $.ui.keyCode.ENTER) {
// e.preventDefault();
// }
//});
$(‘#btnShowData’).button().click(function (e, ui) {
alert(JSON.stringify(data));
e.preventDefault();
});
data.rows = [
{ RegionID: 1, RegionDescription: ‘Eastern’ },
{ RegionID: 2, RegionDescription: ‘Northern’ },
{ RegionID: 3, RegionDescription: ‘Southern’ },
{ RegionID: 5, RegionDescription: ‘Testing’ },
{ RegionID: 4, RegionDescription: ‘Western’ }
];
LoadGrid(data);
$(‘#btnShowData’).show();
});
</script>
</form>
</body>
</html>
I had to add the class .editable to narrow down cancelling the Enter Key only when editing an inline jqGrid entry.
[code]
$(document).on(‘keydown’, ‘.ui-jqgrid .editable’, function (e, ui) {
if (e.keyCode === 13) {
e.preventDefault();
}
});
[/code]
Hi Tony,
Unfortunately, the change you made didn’t fix the issue. I had already tried adding $.jgrid.defaults to the extend myself, but that didn’t work. My default overrides are ignored.
Excellent product by the way. I am using it extensively, with many of its features and configurations. Awesome!
Marv
tony said:
Hello,
Many thanks. Just fixed the problem in GitHub.
Please let me know if this fix works.
Regards
Hi Tony,
The fix works great! Thanks.
Regards, Marv
tony said:
Hello,
In which brower is this. I can
OlegK said:
Hi Marv,
I think it's the old problem described here and here. As the workaround you can include
$('#tabGrid').triggerHandler('jqGridAfterGridComplete');
after
$('#tabGrid').jqGrid('setFrozenColumns');In my opinion the method setFrozenColumns should execute the event handler
tony said:
Hello,
Many thanks. Fixed in GitHub
Regards
Hi Tony,
Thanks for the quick fix. It does fix the sorting issues when frozen columns are used, BUT, the issue with the rows sliding under the frozen columns is still there.
The test case is:
OlegK said:
Sorry, but how you imagine to find the reason with such “bug report”. Do you use local sorting or remote sorting (or use loadonce: true option)? Do you have problem with sorting in all columns of in some columns?
If you can't analyse to problem yourself, where is the test case (so other people could analyse the problem)? One can confirm the bug and fix it only if one can reproduce the problem.
Test Case: http://app.thecybersafe.net/jqGridTest.aspx
Sorry, since the bugs are so obvious I thought it wouldn't need a test case. There are two issues:
1) the frozen columns feature doesn't work until you page the grid OR select an entry from the rowList dropdown.
2) clicking on the column headers for sorting does nothing. Icon remains the same and the rows do not re-sort.
Tony,
Thank you that change worked great! I needed the unformat as well so I implemented them as shown below.
Can the unformats be called from $.fn.fmatter somehow as well?
Marv
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
function isNumeric(number) {<br /> return !isNaN(parseFloat(number)) && isFinite(number);<br /> }<br /> function formatInteger(number) {<br /> return isNumeric(number)<br /> ? $.fn.fmatter("integer", number)<br /> : $.jgrid.formatter.integer.defaultValue;<br /> }<br /> function formatNumber(number) {<br /> return isNumeric(number)<br /> ? $.fn.fmatter("number", number)<br /> : $.jgrid.formatter.number.defaultValue;<br /> }<br /> function formatCurrency(number) {<br /> return isNumeric(number)<br /> ? $.fn.fmatter("currency", number)<br /> : $.jgrid.formatter.currency.defaultValue;<br /> }<br /> function unformatInteger(number) {<br /> var parts = number.split($.jgrid.formatter.number.decimalSeparator);<br /> var out = parseInt(parts[0].replace(/[^0-9-]/g, ''));<br /> return isNumeric(out) ? out : 0;<br /> }<br /> function unformatNumber(number) {<br /> var op = $.jgrid.formatter.number;<br /> var re = /([.*_'(){}+?])/g;<br /> var sep = op.thousandsSeparator.replace(re, "$1");<br /> var stripTag = new RegExp(sep, "g");<br /> var out = number.replace(stripTag, "").replace(op.decimalSeparator, '.');<br /> return isNumeric(out) ? out : 0.0;<br /> }<br /> function unformatCurrency(ret) {<br /> var op = $.jgrid.formatter.currency;<br /> var re = /([.*_'(){}+?])/g;<br /> var sep = op.thousandsSeparator.replace(re, "$1");<br /> var stripTag = new RegExp(sep, "g");<br /> if (op.prefix && op.prefix.length && ret.indexOf(op.prefix) > -1) {<br /> ret = ret.substr(op.prefix.length);<br /> }<br /> if (op.suffix && op.suffix.length && ret.indexOf(op.suffix) > -1) {<br /> ret = ret.substr(0, ret.length - op.suffix.length);<br /> }<br /> ret = ret.replace(stripTag, '').replace(op.decimalSeparator, '.');<br /> return isNumeric(ret) ? ret : 0.0;<br /> }<br /> <br /> |
Devised my own solution that allows for formatting integers, numbers and currency using jqGrid's localization configurations:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<br /> function isNumeric(number) {<br /> return !isNaN(parseFloat(number)) && isFinite(number);<br /> }<br /> function formatInteger(number) {<br /> return isNumeric(number) ? $.fmatter.util.NumberFormat(Math.floor(number), $.jgrid.formatter.integer) : number;<br /> }<br /> function formatNumber(number) {<br /> return isNumeric(number) ? $.fmatter.util.NumberFormat(number, $.jgrid.formatter.number) : number;<br /> }<br /> function formatCurrency(number) {<br /> return isNumeric(number) ? $.fmatter.util.NumberFormat(number, $.jgrid.formatter.currency) : number;<br /> }<br /> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top