This is a migrated thread and some comments may be shown as answers.

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

3 Answers 44 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dimitar
Top achievements
Rank 1
Dimitar asked on 23 Aug 2017, 05:21 PM

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}}"      />

3 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Tsonev
Telerik team
answered on 24 Aug 2017, 07:51 AM
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.
0
Dimitar
Top achievements
Rank 1
answered on 24 Aug 2017, 09:02 AM
Thank you again  for the brilliant support 
0
Ella
Top achievements
Rank 1
answered on 29 Sep 2017, 05:48 AM
I think what brilliant support !
Tags
General Discussion
Asked by
Dimitar
Top achievements
Rank 1
Answers by
Nikolay Tsonev
Telerik team
Dimitar
Top achievements
Rank 1
Ella
Top achievements
Rank 1
Share this question
or