jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Grid validation
Tagged: datagrid control, jqxgrid, validation
This topic contains 4 replies, has 3 voices, and was last updated by dmausner 9 years, 2 months ago.
-
AuthorGrid validation Posts
-
Hi,
I would like to do validation for values. How to achieve this for Grid values.
For Ex: I want only numeric value in one column. The other row should only display chars.
Hi naveen,
The following sample shows how to implement validation of the Grid values: cellediting.htm. You can set a validation function to each column which accepts the edited value as parameter. If the edited value is not valid, you can return false. If the value is valid, return true.
Example:
validation: function (cell, value) { if (value < 0 || value > 150) { return { result: false, message: "Quantity should be in the 0-150 interval" }; } return true; }
Best Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter,
I would like to assign the same validation while on click on a submit button. If values of particular column are empty, then I would like to trigger the validation. How to achieve this kind of validation? Thank you.
Hi naveen,
You can use the Grid’s getrows method to get all rows. Then you can loop through the rows and their values and to check whether correct values are assigned. There’s a showvalidationpopup method which you can use to display validation message where necessary or you can implement your custom validation logic. jqxGrid does not have the feature you need, built it.
Best Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI had the idea to perform cell validation in my app.
I add a row and initialize the cells i need. But some cells are null because they must be filled by the user.Problem: If the user immediately punches my “Save” button (as suggested by the original poster) the cell validation callback is not called.
However if they enter a value, validation is called, usually.The doc doesn’t state any rules for when validation occurs.
Systems of the past have the rule that cell validation is called whenever focus leaves an editable record in which cell validation is defined. If so, we could catch the guy who punches “Save” without filling in the blanks.
It would be preferable, you see, to do cell-level validation, instead of waiting for a save event, then looping thru potentially thousands of rows to validate things that were not recently changed.
I hope this is clear. I would like the grid to trigger a cell validation (defined in the columns hash) if focus leaves an editable row.
-
AuthorPosts
You must be logged in to reply to this topic.