This is a migrated thread and some comments may be shown as answers.

Required validation on a spreadsheet cell.

3 Answers 139 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 27 Sep 2018, 12:41 PM

Hi,

I'm using the Telerik spreadsheet with MVC wrappers to create an input form and am trying to create a validation error when a cell is empty. I've tried various things along the lines of the below. The obvious way to do this seems to be to set AllowNulls = false but this doesn't behave in the same way that other custom validation does, it immediately adds a red validation check to every null cell with the validation check applied and never triggers the message supplied in the MessageTemplate. If setting AllowNulls(true) then it seems like the custom validation rule doesn't trigger on empty cells, so it seems like I can use the custom validator to check for anything other than a cell being empty. 

cells.Add()
                          .Validation(validation => validation
                            .DataType("custom")
                            .From("LEN(B" + currentRowNo + ") > 0")
                            .AllowNulls(false)
                            .Type("reject")
                            .TitleTemplate("A Provider Name is Required")
                            .MessageTemplate("Please enter a Provider Name"));

 

Regards

Michael

3 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 01 Oct 2018, 08:16 AM
Hi Michael,

As you have suggested, setting the AllowNulls() option to false would be the proper approach in the described scenario. Also, the red triangle that initially appears on those cells is expected. In signifies a cell with validation violation. The validation message, however, will only display upon a cell value change. For example, if you fill some text in that cell, focus another cell, click twice on the first cell to edit it, and delete its contents, the validation message will be displayed.

May I ask you explain a bit in detail, what is the issue observed at your end? What part of the Spreadsheet behaviour do you find erroneous?

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Michael
Top achievements
Rank 1
answered on 02 Oct 2018, 01:47 PM

Thanks for your response Veselin. I don't think the behavior is erroneous, its just that I would like to show a validation message when certain cells are empty. Some of the validation that we need to apply is a little complicated and includes a case where one of the cells is only required if another cell in the same row has a value, so it would be useful to actually be able to show an error message.

I think what I ideally need is a way to manually fire the validation when the save button is clicked, but you seem to confirm on this post that this isn't possible. https://www.telerik.com/forums/manually-fire-validation-fail-event

It seems like the best option for me is probably to keep the more complicated validation server side and then pass these errors back to client and format into an error message.

Thanks again for your help

Michael

 

 

 

0
Veselin Tsvetanov
Telerik team
answered on 03 Oct 2018, 11:43 AM
Hello Michael,

Thank you for the additional clarification provided.

Yes, that is right. At this stage, the Spreadsheet cell validation could not be triggered manually. That is why, I would suggest you to log such suggestion as a feature request on our Feedback portal. Based on the support it receives from the community, we will decide on whether to proceed with its implementation or not.

Concerning the specific scenario in question, performing the advanced validation server-side seams to be a proper fit for the case.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Spreadsheet
Asked by
Michael
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or