jQuery UI Widgets › Forums › Grid › spreadsheet cell validation
Tagged: columntype, grid, jqxgrid, number, numberinput, validate, validation
This topic contains 2 replies, has 2 voices, and was last updated by mustafa 9 years, 7 months ago.
Viewing 3 posts - 1 through 3 (of 3 total)
-
Author
-
hello I have 2 questions
1. I want to enter numbers into cells alone
2. warning message does not appear to cause?var data = GetVessels(); window.GridEstimationDataSource = { datafields: [ { name: 'VesselID', type: 'string' }, { name: 'VesselName', type: 'string' } ], addrow: function (rowid, rowdata, position, commit) { commit(true); }, deleterow: function (rowid, commit) { commit(true); }, updaterow: function (rowid, newdata, commit) { commit(true); }, localdata: data, async: false, datatype: "array", id: 'VesselID', } var dataAdapter = new $.jqx.dataAdapter(window.GridEstimationDataSource); var numberrenderer = function (row, column, value) { return '<div style="text-align: center; margin-top: 5px;">' + (1 + value) + '</div>'; } var numberrenderer = function (row, column, value) { return '<div style="text-align: center; margin-top: 5px;">' + (1 + value) + '</div>'; } var theme = ""; var datafields = []; var columns = []; for (var i = 0; i < data.length; i++) { var text = data[i].Name; if (i == 0) { var cssclass = 'jqx-widget-header'; if (theme != '') cssclass += ' jqx-widget-header-' + "web"; columns[columns.length] = { pinned: true, exportable: false, text: "", columntype: 'number', cellclassname: cssclass, cellsrenderer: numberrenderer }; } datafields[datafields.length] = { name: text }; columns[columns.length] = { text: text, datafield: text, width: 80, align: 'center', validation: function (cell, value) { if (value < 0 || value > 100) { return { result: false, message: "Quantity should be in the 0-100 interval" }; } return true; }, initeditor: function (row, cellvalue, editor) { editor.jqxNumberInput({ decimalDigits: 0 }); } }; } var source = { unboundmode: true, totalrecords: data.length, datafields: datafields, updaterow: function (rowid, rowdata) { } }; var dataAdapter = new $.jqx.dataAdapter(source); $("#GridEstimation").jqxGrid( { width: '100%', source: dataAdapter, pageable: true, sortable: true, height: '330px', selectionmode: 'singlerow', theme: 'web', editable: true, columns: columns });
Hello mustafa,
You would have to set your columns’ columntype to ‘numberinput’ and use createeditor instead of initeditor, i.e.:
columns[columns.length] = { text: text, datafield: text, width: 80, align: 'center', columntype: 'numberinput', validation: function (cell, value) { if (value < 0 || value > 100) { return { result: false, message: "Quantity should be in the 0-100 interval" }; } return true; }, createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { editor.jqxNumberInput({ decimalDigits: 0 }); } };
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/thank you dimitar
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.