Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Theresa Danowski 16 posts 78 karma points
    Oct 19, 2015 @ 14:22
    Theresa Danowski
    0

    Reuse of datepicker - how to get the value?

    Hello,

    I'm trying to reuse the umbraco Datepicker in a dialogservice together with other inputfields to edit some data.

    This is how I included it so far in the controller:

    $scope.dateValue=new Date();
    $scope.datePicker = {
        editor: "Umbraco.DateTime",
        alias:"datepicker",
        view: 'datepicker',
        config: {
            pickDate: true,
            pickTime: false,
            useSeconds: false,
            format: "YYYY-MM-DD",
            icons: {
                time: "icon-time",
                date: "icon-calendar",
                up: "icon-chevron-up",
                down: "icon-chevron-down"
            }
        }, value: $scope.dateValue
    };
    

    In the view:

     <umb-property property="datePicker">
         <umb-editor model="datePicker"></umb-editor>
     </umb-property>
    

    Before I submit the dialogService, I checked the value in $scope.dateValue but even if I selected another date in the picker, it's still the current date (because I set it to new Date in the beginning).

    I expected the selected date to be stored in the variable I passed as value but it's not working. I was also looking in other forum threads but didn't found something working. Can you tell me how I can access the selected value of the datePicker?

    Thank you in advance and best regards Theresa

  • Peter Bersani 14 posts 34 karma points
    Dec 22, 2015 @ 18:27
    Peter Bersani
    0

    Theresa,

    Did you ever find a solution to this?

    Peter

  • Theresa Danowski 16 posts 78 karma points
    Mar 08, 2016 @ 12:43
    Theresa Danowski
    0

    Hi Peter,

    I built something around the Picker to get the value right from the input-field of the picker and worked with that. I still don't know how to get the value from the picker itself, I'm sorry.

  • Aristotelis Pitaridis 84 posts 402 karma points
    Mar 08, 2016 @ 13:00
    Aristotelis Pitaridis
    0

    The value is property of the $scope.datePicker. This means that you can get the value like this.

    alert($scope.datePicker.value);
    
  • Theresa Danowski 16 posts 78 karma points
    Mar 08, 2016 @ 13:09
    Theresa Danowski
    0

    I have tried this, too but it has never changed, even if I changed the date in the picker.

  • Aristotelis Pitaridis 84 posts 402 karma points
    Mar 08, 2016 @ 13:14
    Aristotelis Pitaridis
    0

    It is strange. How you try to get the value? Do you try to get the value inside your controller?

  • Theresa Danowski 16 posts 78 karma points
    Mar 08, 2016 @ 13:21
    Theresa Danowski
    0

    I have tried it in the controller, for example with the console.log or the debugger, but also in the model for a quick look.

    It returned always the value I set before when I created the picker.

  • Aristotelis Pitaridis 84 posts 402 karma points
    Mar 08, 2016 @ 13:26
    Aristotelis Pitaridis
    0

    You are right. I just made a test and for some reason the date picker does not update the value. I have tested it with other views like media picker or content picker and it works so I suppose there is a problem with the Date Picker view.

  • Robin Hansen 135 posts 368 karma points
    Jun 29, 2017 @ 10:43
    Robin Hansen
    0

    Hi All - I think I found a solution to this problem... - I was looking for a DataPicket that took current Date if empty. I've used this string as inspiration.

    This is my View:

    <div class="umb-editor umb-datepicker" ng-controller="Custom.DatePreValue">
    <umb-editor model="datePickerNow"></umb-editor></div>
    

    This is my controller:

    angular.module("umbraco")
    .controller("Custom.DatePreValue",
    function ($scope, $filter) {
        $scope.dateValue = $scope.model.value;
    
        if (!$scope.model.value) { 
            $scope.dateValue = $filter('date')(new Date, "yyyy-MM-dd hh:mm:ss");
        }
    
        $scope.datePickerNow = {
            view: 'datepicker',
            config: {
                pickDate: true,
                pickTime: true,
                pick12HourFormat: false,
                format: "YYYY-MM-DD HH:mm:ss"
            }, value: $scope.dateValue
        };
    
        $scope.$on("formSubmitting", function (ev, args) {
            $scope.model.value = $scope.datePickerNow.value
        });
    });
    

    Everything works as intented :-)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies