Search field on IPad project

You must Login before you can answer or comment on any questions.

I am trying to use a search box outside a tableview in my IPad project.

Hal pointed me to the right direction:

http://developer.appcelerator.com/question/85611/search-field-not-search-bar

But for some weird reason, when i add the search bar the table view adds a white space above the table (check the screens) below. And i cannot get rid of the 'search bar' look. I just one the field, like we use here at the forum

tks in advance :)

![alt text](http://i56.tinypic.com/f44ihl.jpg "Title 1") ![alt text](http://i56.tinypic.com/33c11mq.jpg "Title 2") ![alt text](http://i56.tinypic.com/f44ihl.jpg "Title 3")

//
// CREATE SEARCH BAR
//
var searchbox = Titanium.UI.createView({
    top:63,
    height:40,
    left:530,
    widht:60
})
 
var searcher = Titanium.UI.createSearchBar({
    barColor:'transparent',
//  backgroundImage:'',
    backgroundColor:'transparent',
    showCancel:false
});
searcher.addEventListener('change', function(e)
{
e.value; // search string as user types
});
searcher.addEventListener('return', function(e)
{
searcher.blur();
});
searcher.addEventListener('cancel', function(e)
{
searcher.blur();
});
 
searchbox.add(searcher);
win1.add(searchbox);
 
 
//
// create table view (
//
tableView = Titanium.UI.createTableView({
    data:data,
        backgroundColor:'white',
    width:325,
    height: 300,
    left:35,
    top: 150,
    filterAttribute:'clientname',
        borderColor:'red',
    border: 1,
    separatorStyle:Ti.UI.iPhone.TableViewSeparatorStyle.NONE
});

5 Answers

look at you "left" and "top" values for how you are laying out the views, I believe that is what is causing some of your problems.

If you want the Search field to occupy the full width of your app, I would do the following:

Set your 'width' as 100% and 'left' to 0, or just remove it.

var searchbox = Titanium.UI.createView({
    top:63,
    height:40,
    left:0,
    width: '100%'
});

Thanks for the tips Aaron and Antonio.

I am not trying to occupy the full width. I just want to get rid of the "bar" style (like the search field here at the forum):

![Search Field](http://i56.tinypic.com/349cjky.jpg "Search Field")

But my problem is the WHITE space this search bar create on top of my tableview. When i add:

tableView.search = searcher;
The tableview seems to create a white space above the actual rows...

any tips?

try this:

tableView.setContentInsets({top:0})
let me know if it works.

— answered 2 years ago by Dan Tamas
answer permalink
2 Comments
  • Hi Tamas,

    Thanks for your input but it didnt work :(

    Daniel

    — commented 2 years ago by Daniel Ander

  • setContentInsets() is undocumented function what is not supported on SDK 1.6.0, use scrollToTop() instead

    — commented 2 years ago by gondo gondo

Your Answer

Think you can help? Login to answer this question!