RadListView method 'isItemSelected' returns wrong value

4 posts, 0 answers
  1. Marc
    Marc avatar
    40 posts
    Member since:
    Oct 2013

    Posted 03 Nov Link to this post

    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

  2. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 07 Nov Link to this post

    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
  3. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 07 Nov Link to this post

    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
  4. Marc
    Marc avatar
    40 posts
    Member since:
    Oct 2013

    Posted 07 Nov in reply to Deyan Link to this post

    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

Back to Top