如何将日期从一个dateEdit设置为另一个。
我有两个dateedit属性。当一个dateEdit(date1)更改时,我需要在另一个dateedit上设置一些值。我创建了具有某些逻辑的ondatechanged函数,然后需要将值设置为date2字段。我已经使用js / jquery进行设置,但是在聚焦或单击更改的date2 Dateedit之后,该值未正确绑定。

在我看来

 @Html.Hidden("dateTemp")
<label>R2Date</label>
@Html.DevExpress().DateEdit(
settings =>
{
settings.Name = "date1";
settings.Properties.NullText = "MM/dd/yyyy";
settings.Properties.EditFormat = EditFormat.Custom;
settings.Properties.EditFormatString = "MM/dd/yyyy";
settings.Width = System.Web.UI.WebControls.Unit.Percentage(27);
settings.Properties.ClientSideEvents.DateChanged = "OnDateChanged";
}).Bind(Model.r2date).GetHtml()


<label>RDate</label>
@Html.DevExpress().DateEdit(
settings =>
{
settings.Name = "date2";
settings.Properties.NullText = "MM/dd/yyyy";
settings.Properties.EditFormat = EditFormat.Custom;
settings.Properties.EditFormatString = "MM/dd/yyyy";
settings.Width = System.Web.UI.WebControls.Unit.Percentage(27);
settings.Properties.ClientSideEvents.DateChanged = "ReportOnDateChanged";
}).Bind(Model.date1).GetHtml()



 [JScript]
    function OnDateChanged(s, e) {
    var dateVal = s.GetText();
   //my logic here
    dateOnchange();
    }
    dateOnchange(){
    //my logic here just need to call reportondatechange()
     ReportOnDateChanged();
    }

    function ReportOnDateChanged(s,e )
    {
     dateVal1 = $("#dateTemp").val(); //dateval1 has some values here
      s.SetDate(dateVal1);//not working how to set the value here
    }

最佳答案

https://documentation.devexpress.com/#AspNet/DevExpressWebScriptsASPxClientControl_GetControlCollectiontopic

这应该做

 var editor = ASPxClientControl.GetControlCollection().GetByName("date2");
            if (editor) {
                editor.SetValue(dateVal1);
            }
            $("#date2").val(dateVal1);

09-19 12:55