Date converter in a RadListView


#1

Following this example: https://stackoverflow.com/questions/47648087/how-do-i-use-a-converter-in-nativescript

I was able to get this to work:

  var observableModule   = require("data/observable");
  var moment                   =  require("moment");
  var pageData                = new observableModule.Observable();
  var page;

  exports.onPageLoaded = function(args) {
      page = args.object;
      var  formatDateTime = {
         toView: function(value) {
            console.log(`value: ${value}`);
            return moment(value).format('YYYY-MM-DD hh:mm');
         }
      }
     
     pageData.set("formatDateTime",formatDateTime);
     pageData.set("receipt",page.navigationContext);
     pagedata.set("sampleDate","2018-02-03T00:00:00Z");
     page.bindingContext = pageData;

 };

XML
<!-- this works fine -->
<Label text="{{ sampleDate, sampleDate | SampleDate}}" />

Now when I try to apply the same to a radlistview it does not work:

 <lv:RadListView items="{{ receipt.data.receipt.data }}" id="receipt" row="3" col="0"> 

                <lv:RadListView.listViewLayout>
                    <lv:ListViewLinearLayout scrollDirection="Vertical" />
                </lv:RadListView.listViewLayout>
                <lv:RadListView.itemTemplate>
                  
                    <GridLayout columns="auto,auto,auto" rows="auto,auto,auto,auto,auto" >
                        
                         <!--does not work-->
                        <Label text="{{ arrivalDate, arrivalDate |  formatDateTime }}" row="3" col="1"  />
                        <!-- this work --> 
                        <Label text="{{ arrivalDate }}" row="3" col="2" /> 
                        
                    </GridLayout>

                </lv:RadListView.itemTemplate>
 </lv:RadListView>

Can someone point me in the right direction?


#2

I actually faced similar issue here Problems using data converter with RadAutoCompleteTextView where my data converter works everywhere except with RadAutoComplete


#3

I think you have to the parent’s binding context.