How to tell that cell validation errors exist?

Posted by: c17 on 8 September 2017, 11:33 am EST

  • Posted 8 September 2017, 11:33 am EST

    Hi,

    I am using date cells, currency cells, and so on in my grids.  For each of these, I am using the intrinsic cell type properties for range validation.

    For example, in one scenario, the date cells have a minimum value of 1/1/2012, and a maximum value of 12/31/2012.  When the user enters an invalid date (for example 2/31/2012), or a date outside the maximum/minimum range (for example, 12/31/2011), the grid turns the forecolor Red and the backcolor Yellow to indicate a validation error.  (So far, so good!)

    I need to take the validation one step further.  When a postback occurs, I want to notify the user:  "You have invalid date entries.  Please check and correct."  There are a number of ways I could do the notification (either client-side or server-side) but what I need to know is, how can I tell (either client-side or server-side) that there are cells that have failed validation?

    (Note:  EnableClientScript is set to True.)

    Thank you,

    C17

  • Posted 8 September 2017, 11:33 am EST

    Hello,

    You may set the error message for validation using this:

                DateTime min = new DateTime(2000, 1, 1);

                DateTime max = new DateTime(2010, 12, 31);

                FarPoint.Web.Spread.DateTimeCellType dt = new FarPoint.Web.Spread.DateTimeCellType(min, max, "Enter Correct Date!!");         

                FpSpread1.ActiveSheetView.Cells[0, 0].CellType = dt;

    Once you hover the mouse over the red test it displays the error message.

    Thanks,

     

  • Posted 8 September 2017, 11:33 am EST

    Thank you for the response, Deepak, but that was not the question I am asking.  As I indicated, the Spread already does correctly validate each individual cell.  If the user enters an invalid date, the cell is color-coded, and hovering gives you an appropriate message.  This is working fine.

    What I want to know is this: 

    1) Is there any way, client-side for my Javascript to know that some cells are in an invalid state?  I don't see something as straightforward as sheet property like "HasValidationErrors" (although, of course that would be very convenient and I recommend that it be supported). 

    2) Same question server-side:  On postback, how can my code know that some cells are currently in an invalid state?

    Thank you,

    C17

  • Posted 8 September 2017, 11:33 am EST

    Hello,

    Yes, you are right, there is not a direct way to see if the cell content is invalid neither on the client side nor on the server side. As the cell validation is basically dependent on the celltype it is done implicitly by Spread when the value is being saved in the data model. In case you want to perform validation checks on the client side or server side, you would need to write your own code in the appropriate events to perform the validation depending on what celltype is set for the cell, what is the criteria of a value being considered as a valid value. If you could elaborate your requirement further, I can try creating some examples at my end to guide you ahead on the same.

    Hope it will help you. Please let me know if you have any queries further.

    Thanks,

    Manpreet Kaur

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels