locked
Control for TimeSpan in LightSwitch HTML client RRS feed

  • Question

  • Apology if this issues is discussed already & I am not able to find it.

    I have a Time data type in my SQL data & LightSwitch is not assigning a control to it. In Silverlight client I can easily use the default date time picker, but I am really having a hard time assigning a control for a Time data type in HTML Client.

    I've followed this article, but was unable to change the default text control to a date time picker. I've also tried a business type extension but couldn't figure out how to assign the date time picker to my extended TimeSpan. It will be really helpful for me if someone can guide me to the right direction.

    Thanks.

     

    Divyang Vyas

    Friday, December 27, 2013 5:10 PM

Answers

  • After following this article & getting some knowledge of available input types (from here) I am now able to show a control for time. Here is the code that I've in the render event.

    myapp.AddEditTable_1Item.Table_1Item_StartTime_render = function (element, contentItem) { var startTime = $('<input id="StartTime" type="time" />'); startTime.appendTo($(element)); //contentItem.dataBind('value', function (newValue) { startTime.val(newValue); }); contentItem.dataBind("stringValue", function (newValue) { startTime.text(newValue); })

    startTime.change(function () { contentItem.value = startTime.val }); };

    The problem is the data binding is not working, I can save the record without any error but the StartTime doesn't get any value. 

    Divyang Vyas


    Monday, December 30, 2013 2:05 PM

All replies

  • After following this article & getting some knowledge of available input types (from here) I am now able to show a control for time. Here is the code that I've in the render event.

    myapp.AddEditTable_1Item.Table_1Item_StartTime_render = function (element, contentItem) { var startTime = $('<input id="StartTime" type="time" />'); startTime.appendTo($(element)); //contentItem.dataBind('value', function (newValue) { startTime.val(newValue); }); contentItem.dataBind("stringValue", function (newValue) { startTime.text(newValue); })

    startTime.change(function () { contentItem.value = startTime.val }); };

    The problem is the data binding is not working, I can save the record without any error but the StartTime doesn't get any value. 

    Divyang Vyas


    Monday, December 30, 2013 2:05 PM
  • Thanks Dave,

    But I may have not implemented the data binding correctly, because it is not saving the StartTime.


    Divyang Vyas

    Tuesday, December 31, 2013 3:13 PM
  • Hi,

    I have a method to show real-time in the screen by using some javascript codes. The steps:

    1.Create a LightSwitch Html Client project. Create the tables and screens you need. 

    2.Open the screen which you want to show the real-time in designer. Create a DataItem and add it to screen. Change the type of control to Text. Then edit the Post Render Code. Your Visual Studio will generate a function in behind code. Show in image:

    3.Add code in the function:

    myapp.BrowseInfoes.TimeProperty_postRender = function (element, contentItem) {
        // Write code here.
        this.setInterval(
            function(){
                var currentTime = new Date();
                $(element).text(currentTime.toLocaleTimeString());
            }, 
            1000
            );
    };
     OK! Finish!

    Friday, January 3, 2014 10:25 AM
  • Good one & helpful indeed, thanks for that @Northwinsql. Do you have any idea why my code is not binding the time?


    Divyang Vyas

    Friday, January 3, 2014 11:33 AM