When I click "add new row", required field validation raises exceptions/constraints one cell at a time. i.e. not allowing the rows data to be entered in any other order / or for the entire row to appear in edit mode.
behavior reproducible on BatchEditing demo page: http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx
It seems like I would have noticed this before, so maybe it's update related: I have a RadGrid that has Batch Edit row mode enabled.
Is that intended? Can it be changed with an attribute? if not, how about some client side js? I'll be debugging, but would appreciate an available solution.
Thanks
4 Answers, 1 is accepted
Found "solution" by JavaScript debugging. combination of js errors from GridTemplateColumn:DefaultInsertValue not yet being options in dropdown lists(unhandled js exceptions on adding row in Telerik.Web.UI.WebResource.axd) and ColumnValidationSettings attr: RenderValidatorBeforeEditor="false".
The solution you found is proper one and can be used in your scenario.
Also I am attaching a simple example demonstrating such client-side validation, where you could go through each row, get reference to any of the cells of that row and validate each value. This should be achieved in the client-side OnCommand event of the grid. If the validation fails for any row you could cancel the command, which will prevent the postback.
Regards,
Maria Ilieva
Telerik by Progress
Hi Maria,
I am also having same issue on Batch Editing Row Mode the required field validator not working. I have created a ticket # 1398754. Can you please look into the provide a solution. I try to implement your similar using your example code but it is showing back ground back color if I click on Grid's Save Changes but I am looking to fire required fields on external button Save and Grid's delete is not working.
Regards,
Srinivas
You can use any control outside of the Grid to make it save the changes by following the instructions from Batch Editing Client-side API article, and once you have added the the ValidationSettings key to the Web.config, the RequiredFieldValidator will validate the controls that do not have a valid value.
<
appSettings
>
<
add
key
=
"ValidationSettings:UnobtrusiveValidationMode"
value
=
"None"
/>
</
appSettings
>
To change the background or text color of the Error message that appears from the RequiredFieldValidator, you can use the BackColor and ForeColor properties of this control:
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator1"
runat
=
"server"
BackColor
=
"Teal"
ForeColor
=
"LimeGreen"
ErrorMessage
=
"* This field is required"
>
</
asp:RequiredFieldValidator
>
Kind regards,
Attila Antal
Progress Telerik