Add a local path to the image file name for a RadListView

4 posts, 1 answers
  1. Dimitar
    Dimitar avatar
    45 posts
    Member since:
    May 2014

    Posted 23 Aug Link to this post

    Hi, 

    I am trying to  add the local path folder when image should be displyed in 
    RadListView . I don't want to add this path in array source of the RadListView 

    Is there a way to make something like this or call a function to calculate the path

    <lv:RadListView items="{{ dataItems }}" selectionBehavior="Press"
    itemSelected="itemSelected" >
        <lv:RadListView.itemTemplate >
                   <Image src="{{sourceProperty, localPathVar + '/' + receivedImage}}"      />

  2. Answer
    nikolay.tsonev
    Admin
    nikolay.tsonev avatar
    287 posts

    Posted 24 Aug Link to this post

    Hi Dimitar,

    In this case, you could set a single value to the observable object, which contains the needed path.
    Regarding that, with the help of $parents property, you could access in the XML the RadListView parent bindingContext. Then we could use the path, without the need to set it inside the observable-array.
    Example:
    XML
    <Page xmlns:navigation="navigation/example-page" loaded="onPageLoaded" xmlns:lv="nativescript-telerik-ui-pro/listview" xmlns="http://www.nativescript.org/tns.xsd">
        <lv:RadListView items="{{ dataItems }}" >
            <lv:RadListView.itemTemplate>
                <StackLayout orientation="vertical">
                    <Label fontSize="20" text="{{ itemName }}"/>
                    <Label text="{{ $parents['RadListView'].testParam, $parents['RadListView'].testParam }}" textWrap="true" />
                     
                    <Label fontSize="14" text="{{ itemDescription }}"/>
                </StackLayout>
            </lv:RadListView.itemTemplate>
        </lv:RadListView>
    </Page>

    TypeScript
    import {ObservableArray} from "data/observable-array";
    import {Observable} from "data/observable";
    var tmpObservbale:Observable;
    export function onPageLoaded(args){
        var page = args.object;
        var array = new ObservableArray();
        array.push({itemName:"name1", itemDescription:"description1"});
        array.push({itemName:"name2", itemDescription:"description2"});
        array.push({itemName:"name3", itemDescription:"description3"});
     
        tmpObservbale = new Observable();
        tmpObservbale.set("dataItems", array);
        tmpObservbale.set("testParam", "This is test String");
        page.bindingContext = tmpObservbale;
    }

    Regards,
    nikolay.tsonev
    Progress Telerik
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
  3. Dimitar
    Dimitar avatar
    45 posts
    Member since:
    May 2014

    Posted 24 Aug Link to this post

    Thank you again  for the brilliant support 
  4. Ella
    Ella avatar
    1 posts
    Member since:
    Sep 2017

    Posted 29 Sep Link to this post

    I think what brilliant support !
Back to Top