This question is locked. New answers and comments are not allowed.
Hi, I've a problem with validating the column values in the Grid
Any help would be appreciated. !!
I've StartTime and EndTime Column in my MVC Grid.
I'd like to check whether the value in the StartTime Column is less than the EndTime column. I checked with my model class whether I have any property to compare/Check the values. But I don't find
Here is how I designed my model : Model File Name: AppointmentModels
[DataType(DataType.DateTime)]
public DateTime? StartTime { get; set; }
[DataType(DataType.DateTime)]
public DateTime? EndTime { get; set; }
I tried with Remote Attribute of the Model Property.
[Remote("IsDateLesser", "Opportunity", AdditionalFields = "EndTime")]
[DataType(DataType.DateTime)]
public DateTime? StartTime { get; set; }
Whenever I click the calendar the "IsDateLesser" method is been raised, which I don't like to have. It should raise only when I select the value from the calendar. And also, I'd like to send a modal property as the parameter to the IsDateLesser method.
Below is my IsDateLesser method. EndTime value is always null,
public JsonResult IsDateLesser(AppointmentModels model)
{
if (model.StartTime != null && model.EndTime != null)
{
var obj = model.StartTime;
var obj1 = model.EndTime;
return Json(true, JsonRequestBehavior.AllowGet);
}
else
{
return Json(false, JsonRequestBehavior.AllowGet);
}
}
I'd like to check whether the value in the StartTime Column is less than the EndTime column. I checked with my model class whether I have any property to compare/Check the values. But I don't find
Here is how I designed my model : Model File Name: AppointmentModels
[DataType(DataType.DateTime)]
public DateTime? StartTime { get; set; }
[DataType(DataType.DateTime)]
public DateTime? EndTime { get; set; }
I tried with Remote Attribute of the Model Property.
[Remote("IsDateLesser", "Opportunity", AdditionalFields = "EndTime")]
[DataType(DataType.DateTime)]
public DateTime? StartTime { get; set; }
Whenever I click the calendar the "IsDateLesser" method is been raised, which I don't like to have. It should raise only when I select the value from the calendar. And also, I'd like to send a modal property as the parameter to the IsDateLesser method.
Below is my IsDateLesser method. EndTime value is always null,
public JsonResult IsDateLesser(AppointmentModels model)
{
if (model.StartTime != null && model.EndTime != null)
{
var obj = model.StartTime;
var obj1 = model.EndTime;
return Json(true, JsonRequestBehavior.AllowGet);
}
else
{
return Json(false, JsonRequestBehavior.AllowGet);
}
}
Any help would be appreciated. !!