Bug with custom validation

There's an issue when I have a custom validation for entering a whole, numeric value.

If I enter in 3.5, I receive the invalid pop-up as expected. I then enter 3 and all is good. I then enter 3.5 again and receive the invalid pop-up as expected. I then enter 3 one last time and the validation does not happen nor does the cell data changed event fire.

See attached sample application.

Steps to reproduce bug:
- Enter 3.5 in cell 1A. You'll see two pop-ups.
- Enter 3 in cell 1A. You'll see two pop-ups.
- Enter 3.5 in cell 1A. You'll see two pop-ups.
- Enter 3 in cell 1A. You don't see any pop-ups.

Hi,


Thanks for the sample project.

After an initial test, I observed the issue by using your sample project with Aspose.Cells.GridDesktop v8.2.0.2xxx (latest). After running the project, if I enter 3.5 value into A1, I receive the invalid pop-up as expected. I again enter 3 and all is good which produces two pop ups. I then enter 3.5 again and receive the expected pop-ups again and as before. I lastly enter 3 and the validation does not occur anymore. We need to investigate your issue. I have logged a ticket with an id “CELLSNET-42967” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,


We have evaluated your issue in details.

We think the behavior is correct and expected.
When you do:
1. enter 3.5, it invalidates the value
2. enter 3, the value is accepted
3. enter 3.5, it again invalidates the value.
4. enter 3, because the value is not changed from the last accepted one, so nothing will be fired, and no need to trigger validate event and cell data changed event to be fired again.
Here, when you enter any other value, then the validation will happen where it should, so we think the behavior is correct and as expected.

Thank you.

I’m trying to store a local variable for knowing if there are any validation errors on the main page.


If there are, I don’t want to allow the user to change tabs on my tab control. Currently, if you enter 3.5, select a different tab (don’t hit enter after entering 3.5), you’ll receive the pop-up about the value being invalid but then the tab will still change to the other tab. I’m trying to inject some code in the tabchanging event that checks if there are any validation errors and if so, cancel the tab change.

Since this isn’t validating a 2nd time, it’s not working the way I want.

Do you have any other suggestions for storing this hash table of values the user has entered and whether they have validated?

What method will run before the validation happens that I can inject code to store the value and the result of the validation?


Hi,


Thanks for providing us further details.

I have logged your comments against your issue “CELLSNET-42967” into our database. We will check check your issue/ requirements in details and advise you accordingly. We might provide some other workaround to accomplish your task (if possible).

Once we have an update on it, we will let you know here.

Thank you.
Hi,

sswift:
.... if you enter 3.5, select a different tab (don't hit enter after entering 3.5), you'll receive the pop-up about the value being invalid but then the tab will still change to the other tab.



We have evaluated your issue further. Well, we could not find the issue. Using your sample project with Aspose.Cells.GridDesktop v8.2.0.xxxx, if we enter 3.5 into the A1 cell, it will still focus on to invalidating cell and we cannot change to the other tab at all.


For your other requirements, may be you could use CellValidationFailed or you can also use Validated/Validating event if it suits your requirements.

Thank you.

Can you send an example of a custom validation with the validated event?


I’d like to have a main form with the grid desktop and validated event and a custom validation.

If the custom validation Validate method returns false, i’d like to capture that in the main form Validated event.

Thanks.

Please disregard previous email. I was able to figure out a solution.


Thanks!

Hi,


Good to know that you have figured it out now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

I spoke too soon.


The CellValidationFailed is working as I would expect and this is letting me keep track of an error for the griddesktop control.

However, I need to be able to reset this error value if the user selects cancel when they get the invalid value pop-up from the custom validation.

Is there a way to capture that they selected Retry or Cancel?

What I’d like is a CellValidationSuccceed that fires every time a cell has a custom validation and it succeeds or if the user clicks Cancel and the original, “good” value goes back in the cell.


Please let me know when you’ve had a chance to read my prior posts and if you have any ideas.


Thanks!

Hi,

Thanks for your posting and using Aspose.Cells for GridDesktop.

Could you please provide us some sample code and some screenshots highlighting your issues. So that we could understand your issue better and could explain to development team your requirements.

You can provide us a Word document with screenshots. It will help us look into your issue closely and precisely.

Thanks for your cooperation.

Please try the attached application.

Hi,

Thanks for your posting, providing us a sample project and using Aspose.Cells for GridDesktop.

We were able to reproduce your mentioned issue after running your project. We found the GridDesktop should not activate the Tab2 when the Validation has failed. It should remain in Tab1.

I have attached the screenshots showing the running of your project for development team reference.

We have logged your comments in our database against this issue with the project you provided and screenshots. Once, there is some fix or other update for you, we will let you know asap.

Hi,


We have evaluated your issue further.

Well, actually the issue is not related to GridDesktop, as you have used other controls like tabcontrol in your project, you need to evaluate the business logic and check yourself to prevent the tabchange event after the failure on validation, here is our solution below:
e.g
Sample code:

namespace AppForShowingThemBugs
{
public partial class Form1 : Form
{
public static int Counter = 0;
public bool validationresult = false;
public Form1()
{
InitializeComponent();

MessageBox.Show(
“Steps to reproduce issue:\r\n\r\n” +
" - Enter 3.5 in cell 1A and before clicking enter, click on Tab 2.\r\n" +
" - You’ll see the pop-up to Retry or Cancel.\r\n" +
" - Click Retry.\r\n" +
" - The tab control changes to Tab 2.\r\n\r\n" +
“I would like to keep Tab 1 selected.”);

IGekoCustomValidation greaterThanZero = new GreaterThanOrEqualToZero(this);
ICustomValidation customValidation = new GekoCustomValidation(greaterThanZero);
gridDesktop1.GetActiveWorksheet().Validations.Add(0,0, customValidation);
gridDesktop1.GetActiveWorksheet().Validations[0, 0].CustomMsgForStopEdit = “Please enter a valid number.”;
gridDesktop1.GetActiveWorksheet().SetFocusedCell(0, 0);
}
public void SetEnable(bool v){
ultraTabPageControl2.Enabled=v;
}

}

public class GreaterThanOrEqualToZero : IGekoCustomValidation
{
Form1 form;
public GreaterThanOrEqualToZero(Form1 fm)
{
form = fm;
}
public bool Validate(object value)
{
if (value == null ||
(value != null && String.IsNullOrEmpty(value.ToString()))) return true;

bool retVal = false;

int d = 0;
try
{
d = int.Parse(value.ToString());
if (d >= 0) retVal = true;
}
catch
{
retVal = false;
}
form.SetEnable( retVal);
return retVal;
}
}

public interface IGekoCustomValidation
{
bool Validate(object value);
}

}


Hope, this helps a bit.

Thank you.

The issues you have found earlier (filed as CELLSNET-42967) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.