Hi,
How to set date format mm/dd/yyyy in date validation(its a calendar control on aspose.grid.web where we make date column )?
Thanks,
Jairam
Hi,
How to set date format mm/dd/yyyy in date validation(its a calendar control on aspose.grid.web where we make date column )?
Thanks,
Jairam
Hi Jairam,
I think you may try the sample code in Page_Load event:
if(!IsPostBack)
{
GridWeb1.ForceValidation = true;
WebCells cells = GridWeb1.WebWorksheets[0].Cells;
cells["C3"].Custom = "mm/dd/yyyy";
cells["C3"].CreateValidation(ValidationType.Date, true);
}
When you submit / save the grid data, validation is applied and your desired format will be applied.
Thank you.
Hi,
Thanks for the above suggestions we've implemented it but the problem is different.We want a proper format when the user selects from the datepicker of the aspose grid.
During binding it gives a proper format but after binding when user selects a date the date format is changed back to yyyy-mm-dd.Below is the sample code which we are using
BindCol = new BindColumn();
Valid = new Validation();
BindCol.Caption = "Coverage Start Date";
BindCol.DataField = "CoverageStartDate";
BindCol.Width = new Unit(100, UnitType.Point);
Valid.ValidationType = ValidationType.Date;
BindCol.CustomFormat = "MM/dd/yyyy";
BindCol.Validation = Valid;
BindCol.Styl
Please let us now if the code written by me is proper else suggest for the proper code.
Thanks,
Jai
Hi,
Using BindColumn.CustomFormat only affect the displaying format. The control only accecpts "yyyy-mm-dd" input format at client side currently. If want use another input format, you may use the regular expression validation and convert the input to datetime manually.
I have assigned the validation type for a column to Date . When I select a date from the Date picker on the column it shows the date in yyyy-mm-dd format , which is the default and is valid.
After I set and the regular expression as \\d{2}/\\d{2}/\\d{4} to accept a date in mm/dd/yyyy format. Now when i select a date from the date picker the yyyy-mm-dd format is no longer valid.
However, the regular expression written by me seems to be wrong. Please give me a valid regular expression for date in mm/dd/yyyy format.
I also want to navigate through the cells in the grid using tab key press. Pressing tab key on the grid does not take me to the next cell from the current active cell.
Please let me know which property of the Aspose grid can help me navigate through cells using tab key press.
Hi,
When you apply the custom regular expression validation for a cell i.e. @"\d{2}/\d{2}/\d{4}"; the previous date validation will be eliminated. Following is my testing code which works fine for regular custom expression.
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
GridWeb1.ForceValidation = true;
WebCells cells = GridWeb1.WebWorksheets[0].Cells;
WebCell cell = cells["C3"];
// Regular expression.
cell.CreateValidation(ValidationType.CustomExpression, true);
cell.Validation.RegEx = @"\d{2}/\d{2}/\d{4}";
}
}
Currently Arrow keys, enter key are used to navigate from one cell to another. We will check and support tab key for navigation also in our future versions.
Thank you.
Hi ,
I am trying to use a Date validation type to the column and for this column I am applying the reqular expression to accept mm/dd/yyyy format. I would like to use both the features of Date time picker and custom validation which accepts mm/dd/yyyy format.
The regular expression works only if I give up Date validation on the column.
Is there any way that I can use both .
Please reply quickly
Hi jairam,
Well, Date Validation and Custom Expression validation are not possible at the same time on a cell. If you apply both on a cell, the last validation will be overriden.
And regarding tab key support (for navigation b/w cells), we will support it soon,
Thank you.