ProgressNS / nativescript-ui-feedback

This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Other
115 stars 21 forks source link

Programmatic RadListView doesn't fill first and last element #1428

Closed philsuero closed 4 years ago

philsuero commented 4 years ago

Tell us about the problem

A RadListView created programmatically doesn't fill the first and last element (doesn't trigger the itemLoadingEvent for those).

Which platform(s) does your issue occur on?

Both

Please provide the following version numbers that your issue occurs with:

Please tell us how to recreate the issue in as much detail as possible.

  1. Create an array with the information you want to show:
    var nameArray = [];
    for (let index = 0; index < 10; index++) {
        nameArray.push({name: 'Name '+ (index+1)});
    }
  2. Create an RadListView object:
    const listView = new radListViewModule.RadListView();
  3. Set the itemViewLoader to create a view for each item:
    listView.itemViewLoader = () => {
        const label = new Label();
        label.id = 'label';
        label.text = "Generic text"
        return label;
    };
  4. Set the items attribute:
    listView.items = nameArray;
  5. Add an itemLoadingEvent event listener in order to show the right information:
    listView.on(radListViewModule.RadListView.itemLoadingEvent, (args) => {
        args.view.getViewById('label').text = nameArray[args.index].name;
    });

    6: When you ran it, the first and the last element will not trigger the itemLoadingEvent. Hence, the text showed for the first and last element will be "Generic text"

Captura de Tela 2020-06-04 às 17 15 15
facetious commented 4 years ago

The two extra views you see there are the header view and the footer view. You can customize them, or you can remove them entirely.

The header and footer views do not generate itemLoadingEvents.

philsuero commented 4 years ago

Great, it worked. Thank you for taking the time to answer me!