jQWidgets Forums

jQuery UI Widgets Forums Editors DateTimeInput Defaulting Value of jqxDateTimeInput

This topic contains 7 replies, has 3 voices, and was last updated by  abcd 11 years, 10 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • Defaulting Value of jqxDateTimeInput #4914

    csoga
    Participant

    Hi,

    I am extracting the following values from two different columns in a Jqx Grid object:

    Start_Date = “2012-05-06” (in yyyy-mm-dd format)
    Start_Time = “21:40:00”

    I have the following jqxDateTimeInput objects that I need to default to the above values for editing.

    $(“#startDate”).jqxDateTimeInput({ width: ‘120px’, height: ’23px’, formatString: ‘dd-MMM-yyyy’, showCalendarButton: true, theme: theme });

    $(“#StartTime”).jqxDateTimeInput({ width: ‘100px’, height: ’23px’, formatString: ‘HH:mm’, showCalendarButton: false, theme: theme });

    I have tried using both SetDate method and setting the Value property without any success. In all cases, the fields are defaulted to the current date and time.

    Any idea what I’m doing wrong?

    Thanks!

    Defaulting Value of jqxDateTimeInput #4916

    Peter Stoev
    Keymaster

    Hi csoga,

    The method is called ‘setDate’ and to change the Date, you need to use it, not ‘SetDate’.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Defaulting Value of jqxDateTimeInput #4926

    csoga
    Participant

    I have tried the following 3 variations and the dates are always set to the current date instead of the date I am extracting from the Grid (see above).

    $(‘#startDate’).jqxDateTimeInput(‘SetDate’, $.jqx.dataFormat.formatdate(new Date(new Date(Start_Date).getFullYear(), new Date(Start_Date).getMonth(), new Date(Start_Date).getDate()+1), ‘dd-MMM-yyyy’));

    $(‘#startDate’).jqxDateTimeInput(‘SetDate’, new Date(new Date(Start_Date).getFullYear(), new Date(Start_Date).getMonth(), new Date(Start_Date).getDate()+1));

    $(‘#startDate’).jqxDateTimeInput(‘SetDate’, new Date(Start_Date));

    I have also tried the following for the Time formatted input and it always defaults to the current time instead of the time extracted from the grid:

    $(‘#StartTime’).jqxDateTimeInput(‘SetDate’, $.jqx.dataFormat.formatdate(new Date(Start_Time), ‘HH:mm’));

    Defaulting Value of jqxDateTimeInput #4927

    Peter Stoev
    Keymaster

    Hi csoga,

    The ‘setDate’ method expects a Date object, not a string, formatted string or something else.

    Here’s how to set a Date with jqxDateTimeInput.

    var date = new Date();
    date.setFullYear(1999, 0, 3);
    $("#jqxWidget").jqxDateTimeInput('setDate', date);

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Defaulting Value of jqxDateTimeInput #4934

    csoga
    Participant

    Thanks for the feedback, Peter.

    What you mentioned is what \i thought I was doing in some of the options I tried (specifically option 2)… Or is it failing because it is being performed in-line?

    $(‘#startDate’).jqxDateTimeInput(‘SetDate’, new Date(new Date(Start_Date).getFullYear(), new Date(Start_Date).getMonth(), new Date(Start_Date).getDate()+1));

    I will try what you suggested later and see if it will work….

    Thanks,
    Cyril

    Defaulting Value of jqxDateTimeInput #4935

    Peter Stoev
    Keymaster

    Hi Cyril,

    There’s is no ‘SetDate’ method. Calling ‘SetDate’ will have no effect. You need to use ‘setDate’.

    var date = new Date();
    date.setFullYear(1999, 0, 3);
    $("#jqxWidget").jqxDateTimeInput('setDate', date);

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Defaulting Value of jqxDateTimeInput #4990

    csoga
    Participant

    Thanks Peter… for pointing out the typo I had in my code. Fixed it and it worked like a charm.

    I played around with defaulting the time a bit and got it working as well. In case there is anyone wondering how I fixed that, the following is what I did to set the default of the field to the value retrieved from the grid (which was in the format “HH:MM:SS”):

    //Object Definition
    $(“#startTime”).jqxDateTimeInput({ width: ‘100px’, height: ’23px’, formatString: ‘HH:mm’, showCalendarButton: false, theme: theme });

    Start_Time = “21:30:00”; // Initial value retrieved from the grid.
    sTime = ConvertToDate(Start_Time); // A function I wrote to convert the value of Start_Date to a valid date

    //Set the default of the field…
    $(‘#startTime’).jqxDateTimeInput(‘setDate’, new Date(sTime));

    // Custom function to return a valid date from a time.
    function ConvertToDate(stringTime)
    {
    var date = new Date();
    hours = stringTime.substr(0,2);
    minutes = stringTime.substr(3,2);
    date.setHours(parseInt(hours));
    date.setMinutes(parseInt(minutes));

    return date;
    }

    Cheers,
    Cyril

    Defaulting Value of jqxDateTimeInput #22866

    abcd
    Member

    Hi,

    I want to set blank date instead of default date .there should be no date present before click on the calendar or on the text box.
    how can i do it.I tried using setDate method.
    It doesnt work for me.

    Cheers,
    Deep

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.