Invalid Date Format in FarPoint Control

Posted by: anand-r on 8 September 2017, 8:37 pm EST

  • Posted 8 September 2017, 8:37 pm EST

    Hi

    When we give any wrong date format in the Far Point Grid, we are gettting the tooltip as "Invalid Date Value" also cell shows Red Colour. It captures the error and happens in the browser.

    It does not happens in our code when we press Submit. Can you please let us know whether can an interrogate the Farpoint Spread control to see if that has some kind of flag set and then stop the Submit process if the flag indicates an error.

    Please reply. Thanks in Advance.

    Regards

    K.V.B.Gururaaja

  • Posted 8 September 2017, 8:37 pm EST

    Hello,

    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
  • Posted 8 September 2017, 8:37 pm EST

    Hi,

    Thanks for your reply. We will investigate it further and keep you posted our queries.

    Regards

    K.V.B.Gururaaja

  • Posted 8 September 2017, 8:37 pm EST

    Hi,

    Thanks for your reply.

    Please find below our queries further.

    If the cell is set to a date field (“mm/dd/yyyy”) format, but is populated by the user in “m/dd/yyyy” (missing leading zero) format, the validation throws an error. How can FarPoint Spread handle missing leading zeros in dates (which can happen when someone pastes data from excel sheet). Is there a setting in FarPoint Spread that needs to be set to handle this case?

     

    Also, how do we handle this in our “btnSubmit_click” event handler in the code behind? Can we interrogate the FarPoint Spread component to see if an error was encountered in the data by the component so we can handle this in our submit event handler?

     

    Please reply for the above.

     

    Thanks

     

    K.V.B.Gururaaja

  • Posted 8 September 2017, 8:37 pm EST

    Hello,

    Please have a look at the attached sample, where in I have set the DateTimeFormat to 'MM/dd/yyyy" so when I as a user eners any date in the M/dd/yyyy format(Eg: 2/12/2012). When I click on the update button it automatically appends the leading zero and does not throws any error. I have attached a video for the same. YOu may try using the code in the attached sample at your end to see if it works for you.

    Secondly, Spread does not alters any flag or property explicitly when it validates the dates in the cell on the server side, it implicitly handles the same. As mentioned in the above post, if you need to perform a validation, you would need to manually do the same in your button click event by retrieving the cell values and comparing the same.

    Hope it helps.

    Thanks,

    Manpreet Kaur

    2013/04/Video and sample.zip
  • Posted 8 September 2017, 8:37 pm EST

    Hi

    Thanks for your reply with sample.

    Thanks

    K.V.B.Gururaaja 

     

     

  • Posted 8 September 2017, 8:37 pm EST

    Hi,

    Thanks for your reply.

    We are setting the Date Format to 'MM/DD/YYYY' using FarPoint DateCalendarCellType() method in our code and if user enters in “m/dd/yyyy” (missing leading zero) format in the Front End, the validation throws an error.

    Sample code below:

    FarPoint.Web.Spread.Extender.DateCalendarCellType ex_cal = new FarPoint.Web.Spread.Extender.DateCalendarCellType();

    ex_cal.DateFormat = "MM/dd/yyyy";

    Can you please let us know how FarPoint handles this case and how error is identified by the component so that we can handle this in our submit event handler.

    Thanks

    K.V.B.Gururaaja

  • Posted 8 September 2017, 8:37 pm EST

    Hello,

    Could you please provide me with a sample application depicting your issue so that I can replicate the issue at my end and debug it further.

    Thanks,

    Manpreet Kaur

  • Posted 8 September 2017, 8:37 pm EST

    Hi,

     Please find attached a sample solution. This runs on .Net Framework 3.5, VS 2008

     Best regards.

    2013/04/InvalidDateFormat.zip
  • Posted 8 September 2017, 8:37 pm EST

    Hello,

    I apologize for the delayed response. You are using an old version of Spread. I would request you to test the issue with the latest version of Spread i.e. Spread.Net7, which you may download from the following link:

               http://www.componentone.com/SuperProducts/SpreadStudio/

    I would suggest you to try using the code suggested in the sample posted in the above thread. Please let me know if the issue still persists.

    Thanks,

    Manpreet Kaur

  • Posted 8 September 2017, 8:37 pm EST

    Hello,

    Thank you much for the information. The code you have suggested works as desired to take care of the missing leading zeros. But it takles away the nice feature of the AJAX calendar being displayed when the cell is clicked. Is there  anyway the same functionality can be replicated by using Farpoint.Web.Spread.Extender.DateCalendarCellType()?

     Much appreciate your help.

    Guru

  • Posted 8 September 2017, 8:37 pm EST

    Hello,

    There is not a direct way to achieve the desired functionality. You would need to handle the input value using the javascript. You can use the EditModeStopped event i.e. raised as soon as the user stops editing. In this event you can get the value of the cell and accordingly reset the same with leading zeros. Please have a look at the attached sample that depicts the same.

    Hope it helps.

    Thanks,

    Manpreet Kaur

    2013/05/LeadZero.zip
Need extra support?

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

Learn More

Forum Channels