Nativescript: RadListView, how to switch listViewLayout programatically -




i have common scenario when user can switch list layout between list , grid view tapping icon. before had 2 lists - listview standard list layout , radlistview grid view. hided , showed them depending on required "mode". since radlistview has required layouts theoretically can have 1 list , reuse switching layouts. haven't found how directly in xml (that best approach if any), i'm thinking of doing programatically in code behind.

here try:

    function _switchlistviewlayout() {         const list = modal.getviewbyid( 'list' )         let layout          if ( list.listviewlayout instanceof listviewlinearlayout ) {             // switch grid             layout = new listviewgridlayout()             layout.scrolldirection = 'vertical'             layout.itemheight = 150             layout.spancount = 2         }          else if ( list.listviewlayout instanceof listviewgridlayout ) {             // switch list             layout = new listviewlinearlayout()             layout.scrolldirection = 'vertical'             layout.itemheight = 66         }          list.listviewlayout = layout         list.refresh()     } 

is correct way or i'm doing wrong?

yes way can change listviewlayout of radlistview component. see have call .refresh() method, not necessary have set new value listviewlayout property.

you can change in official examples radlistview here.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -