Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / How to set value to a datepicker through Javascript ()???

How to set value to a datepicker through Javascript ()???

New Discussion
Kishore A
Kishore A asked on Jul 8, 2014 8:05 AM

My JAVASCRIPT Function in View:

<script type=”text/javascript”>
$(function () {

function ProgrammeAllotmentModel() {
this.ProposalDetailsIDKey = “”;
}

$(document).delegate(“.ddlProposalDetail”, “igcomboselectionchanged”,
function (evt, ui) {
var id = evt.target.id;

if (ui.items && ui.items[0]) {

var myRecipe = new ProgrammeAllotmentModel();
myRecipe.ProposalDetailsIDKey = ui.items[0].value;

var postData = JSON.stringify(myRecipe);

$.ajax({
url: ‘@Url.Action(“/LoadProposalDetailsByIDKey”)’,
type: ‘POST’,
data: JSON.stringify(myRecipe),
dataType: ‘json’,
contentType: ‘application/json; charset=utf-8’,
success: function (obj) {

var num = id.replace(“ddlProposalDetail”, “”);
alert(num);

$.each(obj, function (key, value) {

alert(value.TentativeFromDateDt);

$(“#TentativeStartDate” + num).igDatePicker(value.TentativeFromDateDt, new Date());

});
},

error: function () {
alert(‘error occured’);
}

});

}
});
});

</script>

Am rendering a partial view which has a datepicker in it.

My partial view :

<td>

@Html
.Infragistics().DatePickerFor(model => model.MyProperty[j].TentativeStartDate).ID(“TentativeStartDate” + j).DateInputFormat(“dd/MM/yyyy”).Width(100).Height(22).ValidatorOptions(m => m.Required(false)).Render()

</td>

My controller function returns  TentativeFromDateDt  Property as {6/25/2014 9:34:59 PM}

Mt model class contains

public Nullable<System.DateTime> TentativeFromDateDt { get; set; }

 

My alert box in  javascript ()  shows:

/Date(1403712299050)/

Sign In to post a reply

Replies

  • 0
    Maya Kirova
    Maya Kirova answered on Jul 7, 2014 8:28 AM

    Hello Kishore ,

     

    Thank you for posting in our forum.

     

    The value can be set via the igEditor widget using the “value” method. For example:

    $(".selector").igEditor("value", new Date(1403712299050));

     

    For more details refer to our API documentation:

    http://help.infragistics.com/jQuery/2014.1/ui.igeditor#methods

    All editors inherit from the igEditor widget and their values need to be set through it.

     

    Let me know if you have any questions.

     

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://pt-br.infragistics.com/support

     

    • 0
      Kishore A
      Kishore A answered on Jul 8, 2014 8:05 AM

      I heartily Thank You Maya Kirova.

      But it is shoing something like " N/Nan/0Nan" 

      but I somehow managed to bring the desired output by setting the value through

      $(".selector").igEditor("value", new Date(value.TentFrmDt));


      where :

      IN Model

      public string TentFrmDt { get; set; } and

       public Nullable<System.DateTime> TentativeFromDateDt { get; set; }

      and

      IN Controller

       TentFrmDt=String.Format("{0:d}", TentativeFromDateDt); 

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Kishore A
Favorites
0
Replies
2
Created On
Jul 08, 2014
Last Post
11 years, 7 months ago

Suggested Discussions

Created by

Created on

Jul 8, 2014 8:05 AM

Last activity on

Feb 12, 2026 9:17 AM