locked
Change Datetime Value HTML using moment.js RRS feed

  • Question

  • Hi, i need to see time in 24 H format and DD/MM/YYYY HH:mm to make more usuable for our customer to select a date and time.

    i make this one : (Working fine on Date)

    contentItem.dataBind("value"function (value) {        if (value) {            $(element).text(moment(value).format("DD/MM/YYYYY"));        }    });

    and test...

    contentItem.dataBind("value"function (value) {
           if (value) {
               $(element).text(moment(value).format("DD/MM/YYYY, HH:mm"));
           }
       });

    This one not working, our are in 12 H format.

    But, i have a problem with this, after select hour or time or any other field, DateTime Field goes Read Only (disappears picker...)

    Thanks for help me! ;)

    Wednesday, September 24, 2014 9:48 PM

Answers

  • Hi,

    I think the format method you used to formate the date caused this kind of issue.

    You could try like below :

    myapp.Home.RowTemplate_render = function (element, contentItem) {
    
        var itemTemplate = $("<div> </div>");
    
        var title = $("<h3>" + moment(contentItem.value.StartDate).format("ddd, MMM Do, h:mm") + "-" + moment(contentItem.value.EndDate).format("h:mma") + "</h3>");
    
        var subTitle = $("<span>" + contentItem.value.Customer.FirstName + " " + contentItem.value.Customer.LastName + " - " + contentItem.value.Customer.Phone + "</span>");
    
        title.appendTo($(itemTemplate));
    
        subTitle.appendTo($(itemTemplate));
    
        itemTemplate.appendTo($(element));
    
    };
    

    For more details about using moment.js in lightswitch,please see link below:

    http://msdn.microsoft.com/en-us/library/jj674624.aspx

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    • Marked as answer by Angie Xu Wednesday, October 8, 2014 2:06 AM
    Monday, October 6, 2014 8:09 AM