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

Fix ListView filter header on top

3 Answers 89 Views
HTML5, CSS, JavaScript
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gonzalo
Top achievements
Rank 1
Gonzalo asked on 21 May 2015, 06:10 PM

Hi, I'd like to make the filter search box to stay fixed on the top of the screen while scrolling through a ListView on a mobile app.

Is that possible?

This is my code:

 

 <ul data-role="listview" data-bind="source: dataSource" data-filterable="{ field: 'searchField', placeholder: 'Search...', operator: 'contains', ignoreCase: true }"
            data-template="item-template"></ul>

 

Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 25 May 2015, 12:36 PM
Hello Gonzalo,

You can do this by implementing a custom filter UI. You can put an input element over the ListView and on change of the input, filter the ListView. You can see this implemented here:
http://dojo.telerik.com/afosu

Regards,
Tsvetina
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Gonzalo
Top achievements
Rank 1
answered on 25 May 2015, 09:16 PM

Hi Tsvetina, that doesn't quite work on my enviroment. I'm using the Android theme which fixes the header at the bottom of the screen.

Just try your example and select "Android" and you'll see what I mean.

I need to display the filter at the top of the screen.

 

Any other suggestion?

0
Tsvetina
Telerik team
answered on 27 May 2015, 12:02 PM
Hi Gonzalo,

One option that you have is to create two separate views—one for iOS with a search box in the header and one for Android with a search box in the footer. Then, you can use the Device core plugin to check which is the current OS and open the respective view for filtering.

I have implemented such approach in the attached sample. When you open the drawer and click Search, based on the device platform, a different version of the view is opened. This happens in the click event handler of the link that I have attached during deviceready in app.js:

$("#searchLink").click(function () {
    var platform = device.platform.toLowerCase();
 
    if (platform === "android") {
        app.navigate("views/search-android.html");
    }
    else {
        app.navigate("views/search-ios.html");
    }
});


Regards,
Tsvetina
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
HTML5, CSS, JavaScript
Asked by
Gonzalo
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Gonzalo
Top achievements
Rank 1
Share this question
or