Users need fill form form (about 200-500 rows with two fields) at one time.
This data will edit as one transaction, enabling data editing line by line
causes additional inconvenience of data input.
user open grid - set focus on first inputbox -
type value <tab> (to get focus on next inputbox)
type value <tab>
type value <tab>
etc.
I tested few variants
1. formater returns '<input class="easyui-numberbox">'
and DataGrid
onLoadSuccess; fuction() { $('easyui-numberbox').numberbox( ... );
}
that variant slower too.
2. formater returns input with my functions (code bellow)
var precision = 2;
var mode_edit = false;
var changes = {};
var cur_value = null;
var edit_fmt_a = function(val, data, row) {
var v = parseFloat(val).toFixed(precision);
var a = 'value="' + v + '" row="row' + row + '" rid="' + data.id + '" aid="' + data.account_id + '" rtype="a"';
return !mode_edit ? v : '<input type="text" ' + a + ' onkeydown="return num_filter(event, this)" onfocus="account_data_edit_focus(this)" onblur="account_data_edit_blur(this)" />';
}
this variant is faster, but i need write own fuctions to control numeric input
function num_filter(e/*event*/, o/*object*/) {
var o = $(o);
var v = o.val();
var keyCode = ('which' in e) ? e.which : e.keyCode;
if ($.inArray(keyCode, [8, 9, 35, 36, 37, 38, 39, 40, 45, 46]) != -1) // Special keys
return true;
if (keyCode == 190) { // Dot
if (v.indexOf('.') == -1) {
if (v == '')
o.val('0');
return true;
}
return false;
}
isNumeric = (keyCode >= 48 /* 0 */ && keyCode <= 57 /* 9 */) ||
(keyCode >= 96 /* NUMPAD0 */ && keyCode <= 105 /* NUMPAD9 */);
modifiers = (e.altKey || e.ctrlKey || e.shiftKey);
return isNumeric || modifiers;
}
and functions to check changed fields
window.account_data_edit_focus = function(obj) {
cur_value = parseFloat($(obj).val());
}
window.account_data_edit_blur = function(obj) {
var o = $(obj);
var n = parseFloat(o.val());
o.val(n.toFixed(precision));
var aid = o.attr('aid');
if (cur_value != n) {
var val_a = parseFloat($('input[row=' + o.attr('row') + '][rtype=a]').val());
var val_p = parseFloat($('input[row=' + o.attr('row') + '][rtype=p]').val());
changes[aid] = {aid:aid, rid:o.attr('rid'), a:val_a, p:val_p};
}
}
that all makes code unreadable.
3. I planed test third variant - setup table keydown handler and when <tab> is pressed and edit mode is enabled - enter next row to edit mode.