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

RadListView method 'isItemSelected' returns wrong value

3 Answers 71 Views
ListView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marc
Top achievements
Rank 1
Marc asked on 03 Nov 2016, 03:46 PM

Hello,

I want to implement the multiselection for the RadListViews in our NativeScript project. When the user holds one of the list items (LognPress), he gets into the selection-mode. From now on he should be able to select/deselect items with a normal tap, not LongPress.

I use the isItemSelected method on my RadListView-instance to check, if an item is already selected or not.

 

exports.onItemTap = function(args) {
    //in selection mode...
        if(myListView.isItemSelected(myListView.getItemAtIndex(args.itemIndex))) {
            myListView.deselectItemAt(args.itemIndex);
        } else {
            myListView.selectItemAt(args.itemIndex);
        }
    //...
};

 

For the first time, this scenario already works, but when I navigate to my page for a second time, the isItemSelected method returns false even though the item is selected, so I am not able to deselect an item in Tap event anymore, only with LongPress. (see the GIF in the attachment for demonstration)

This is the content of my Observable:

selectingItems: false,
 
myItems: new observableArrayModule.ObservableArray([]),
 
loadItems: function() {
     var self = this;
 
     //first: remove old items out of the array
     self.clearObservableArray(self.get('myItems'));
 
     for(var i = 0; i < 30; i++) {
         self.get('myItems').push({/*some sample content...*/});
     }
 },
 
 clearObservableArray: function(observableArray) {
     observableArray.splice(0,observableArray.length);
 }

 

You see in my load-function, that I clear the content out of my ObservableArray with the splice method before i fill it with new content as the page is loaded.

I noticed, that I don't run into this issue, when I completely re-init my ObservableArray with self.set("myItems", new observableArrayModule.ObservableArray([])) instead, but that is not an option for me, as I have some trouble with PullToRefresh when I create a new instance of ObservableArray every time I refresh or load new content.

 

You can access the full source code of my code sample here: Link to sample project

The GIF in the attachment demonstrated the explained behaviour of the sample app.

 

My testing environment:

  • NativeScript Framework version 2.3.0
  • Telerik UI For NativeScript Pro version 1.4.1

 

Can you see what I am doing wrong? I am thankful for any advice.

 

Best regards

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 07 Nov 2016, 08:11 AM
Hello Marc,

Thanks for writing and for the attached project.

I would like to inform you that we have been able to reproduce the issue and will investigate.

I will get back to you by the end of the day with more information and possible workarounds.

Thanks for your time!

Regards,
Deyan
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Deyan
Telerik team
answered on 07 Nov 2016, 01:38 PM
Hello Marc,

This is a quick follow-up to let you know that we have been able to implement a fix for your case. You can quickly see if it works for you by using the npm install nativescript-telerik-ui@next version of our plugin. If you are using the PRO version, you can use the tns plugin add nativescript-telerik-ui-pro@next version. This version shows a Trial message for the paid components (Chart, Calendar, DataForm) but it will still be helpful in determining whether things work as expected now.

The same fix will be included in our upcoming official release.

Thanks for your patience and let me know if you need further assistance.

Regards,
Deyan
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Marc
Top achievements
Rank 1
answered on 07 Nov 2016, 03:22 PM

Hello Deyan,

thanks for your fast response and for implementing the fix.

The described scenario with multiselection and pulltorefresh works very well now.

 

Best regards,

Marc

Tags
ListView
Asked by
Marc
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Marc
Top achievements
Rank 1
Share this question
or