Tableview: (not widget) how can I have search ignore rows?

I have a large string table that I’m successfully searching. Unfortunately, my tableview still populates the missing cells, any advice? I figure I’m going to have to alter the actual tableview.lua in order to prevent it from spawning the buttons, but I’m not sure where/how to make the change.

myList = tableView.newList{  
 data=data,   
 default="listItemBg.png",  
 --default="listItemBg\_white.png",  
 over="listItemBg\_over.png",  
 onRelease=listButtonRelease,  
 top=topBoundary,  
 bottom=bottomBoundary,  
 cat="body",  
 order=headers,  
  
  
 categoryBackground="catBg.png",  
 callback = function( row )  
 local isFiltered = false  
 filterText = inputsearch  
  
  
   
 if( filterText ~= "" ) then   
 if( string.find(string.lower( row.title ) , string.lower( filterText )) ) then   
 isFiltered = false   
 globalvarinput=1  
 else  
 isFiltered = true   
 globalvarinput=0  
  
 end  
 end  
 -- if( isFiltered == true) then  
 -- data=data+1  
 -- end  
 local g = display.newGroup()  
  
 if( isFiltered == false ) then  
  
  
  
 local img = display.newImage(row.image)  
 g:insert(img)  
 img.x = math.floor(img.width\*0.5 + 1)  
 img.y = math.floor(img.height\*0.5)   
  
 local title = display.newText( row.title, 0, 0, native.systemFontBold, 24 )  
 title:setTextColor(0, 0, 0)  
 --title:setTextColor(255, 255, 255)  
 g:insert(title)  
 title.x = title.width\*0.5 + img.width + 6  
 title.y = 30  
  
 local subtitle = display.newText( row.subtitle, 0, 0, native.systemFont, 20 )  
 subtitle:setTextColor(80,80,80)  
 --subtitle:setTextColor(180,180,180)  
 g:insert(subtitle)  
 subtitle.x = subtitle.width\*0.5 + img.width + 15  
 subtitle.y = title.y + title.height + 6  
  
 local subtitle2 = display.newText( row.subtitle2, 0, 0, native.systemFont, 20 )  
 subtitle2:setTextColor(80,80,80)  
 --subtitle:setTextColor(180,180,180)  
 g:insert(subtitle2)  
 subtitle2.x = subtitle2.width\*0.5 + img.width + 15  
 subtitle2.y = title.y + title.height + 30  
  
 local origin = display.newText( row.origin, 0, 0, native.systemFont, 20 )  
 origin:setTextColor(0,0,0)  
 --subtitle:setTextColor(180,180,180)  
 g:insert(origin)  
 origin.x = origin.width\*0.5 + img.width + 30  
 origin.y = title.y + title.height + 80  
  
 local bprice = display.newText( row.bprice, 0, 0, native.systemFontBold, 20 )  
 bprice:setTextColor(0,0,0)  
 --subtitle:setTextColor(180,180,180)  
 g:insert(bprice)  
 bprice.x = bprice.width\*0.5 + img.width + 400  
 bprice.y = title.y + title.height + 80  
  
 local gprice = display.newText( row.gprice, 0, 0, native.systemFontBold, 20 )  
 gprice:setTextColor(0,0,0)  
 --subtitle:setTextColor(180,180,180)  
 g:insert(gprice)  
 gprice.x = gprice.width\*0.5 + img.width + 400  
 gprice.y = title.y + title.height + 55  
  
 else  
 --tableView:deleteRow()  
 --tableView:removeItem(self, true)  
 --if(myList.numChildren -1 == 0) then  
 --print("No more btn in the list")  
 --end  
 counter=counter+1  
 print(counter)  
 end   
 return g   
 end   
}  

[import]uid: 77043 topic_id: 36095 reply_id: 336095[/import]

If I understand what you’re doing, why not make a new table of data that only has the records in it that you searched for then load that table which is a subset of the data in to the tableView? [import]uid: 199310 topic_id: 36095 reply_id: 143406[/import]

hey, thanks for replying.

Tried taking your advice, but can’t seem to get it to work. See anything glaring?

for i=1, #tabledata do  
  
  
 local isFiltered = false  
 --filterText = inputsearch  
 filterText = "a"  
  
 if( filterText ~= "" ) then -- Don't filter if filterText is empty.  
 if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false -- Don't filter this one out, we found the string.  
 --gvar=true  
 else  
 isFiltered = true -- Filter it out, search term is not in the string.  
 -- gvar=false  
  
 end  
 end  
 if( isFiltered == false) then   
 searchtable[i] = v  
 end  
 end  
  

(got a little disjointed in the cut and paste, edited to try to clean up the lines) [import]uid: 77043 topic_id: 36095 reply_id: 143423[/import]

After a quick glance, perhaps this could solve the problem:

[lua]

local searchCount = 0

for i=1, #tabledata do

local isFiltered = false
–filterText = inputsearch
filterText = “a”

if( filterText ~= “” ) then – Don’t filter if filterText is empty.
if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then
isFiltered = false – Don’t filter this one out, we found the string.
–gvar=true
else
isFiltered = true – Filter it out, search term is not in the string.
– gvar=false

end
end
if( isFiltered == false) then
searchCount = searchCount + 1
searchtable[searchCount] = v
end
end
[/lua]
[import]uid: 93133 topic_id: 36095 reply_id: 143471[/import]

Thank you so much for the help. To anyone else who has had a similar issue, here is the code that ended up working for me:

for i,v in pairs(storedata) do  
  
 local isFiltered = false  
 filterText = inputsearch  
  
  
 if( filterText ~= "" ) then   
 if( string.find(string.lower( storedata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false   
 else  
 isFiltered = true   
 end  
 end  
 if( isFiltered == false) then   
 searchCount = searchCount + 1  
 searchtable[searchCount] = v  
 end  
 if( isFiltered == true) then  
  
 end  
 end  

Now, if I can get the native text fields to play nicely, I’ll be golden! Again, thank you so much for the help. [import]uid: 77043 topic_id: 36095 reply_id: 143492[/import]

If I understand what you’re doing, why not make a new table of data that only has the records in it that you searched for then load that table which is a subset of the data in to the tableView? [import]uid: 199310 topic_id: 36095 reply_id: 143406[/import]

hey, thanks for replying.

Tried taking your advice, but can’t seem to get it to work. See anything glaring?

for i=1, #tabledata do  
  
  
 local isFiltered = false  
 --filterText = inputsearch  
 filterText = "a"  
  
 if( filterText ~= "" ) then -- Don't filter if filterText is empty.  
 if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false -- Don't filter this one out, we found the string.  
 --gvar=true  
 else  
 isFiltered = true -- Filter it out, search term is not in the string.  
 -- gvar=false  
  
 end  
 end  
 if( isFiltered == false) then   
 searchtable[i] = v  
 end  
 end  
  

(got a little disjointed in the cut and paste, edited to try to clean up the lines) [import]uid: 77043 topic_id: 36095 reply_id: 143423[/import]

After a quick glance, perhaps this could solve the problem:

[lua]

local searchCount = 0

for i=1, #tabledata do

local isFiltered = false
–filterText = inputsearch
filterText = “a”

if( filterText ~= “” ) then – Don’t filter if filterText is empty.
if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then
isFiltered = false – Don’t filter this one out, we found the string.
–gvar=true
else
isFiltered = true – Filter it out, search term is not in the string.
– gvar=false

end
end
if( isFiltered == false) then
searchCount = searchCount + 1
searchtable[searchCount] = v
end
end
[/lua]
[import]uid: 93133 topic_id: 36095 reply_id: 143471[/import]

Thank you so much for the help. To anyone else who has had a similar issue, here is the code that ended up working for me:

for i,v in pairs(storedata) do  
  
 local isFiltered = false  
 filterText = inputsearch  
  
  
 if( filterText ~= "" ) then   
 if( string.find(string.lower( storedata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false   
 else  
 isFiltered = true   
 end  
 end  
 if( isFiltered == false) then   
 searchCount = searchCount + 1  
 searchtable[searchCount] = v  
 end  
 if( isFiltered == true) then  
  
 end  
 end  

Now, if I can get the native text fields to play nicely, I’ll be golden! Again, thank you so much for the help. [import]uid: 77043 topic_id: 36095 reply_id: 143492[/import]

If I understand what you’re doing, why not make a new table of data that only has the records in it that you searched for then load that table which is a subset of the data in to the tableView? [import]uid: 199310 topic_id: 36095 reply_id: 143406[/import]

hey, thanks for replying.

Tried taking your advice, but can’t seem to get it to work. See anything glaring?

for i=1, #tabledata do  
  
  
 local isFiltered = false  
 --filterText = inputsearch  
 filterText = "a"  
  
 if( filterText ~= "" ) then -- Don't filter if filterText is empty.  
 if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false -- Don't filter this one out, we found the string.  
 --gvar=true  
 else  
 isFiltered = true -- Filter it out, search term is not in the string.  
 -- gvar=false  
  
 end  
 end  
 if( isFiltered == false) then   
 searchtable[i] = v  
 end  
 end  
  

(got a little disjointed in the cut and paste, edited to try to clean up the lines) [import]uid: 77043 topic_id: 36095 reply_id: 143423[/import]

After a quick glance, perhaps this could solve the problem:

[lua]

local searchCount = 0

for i=1, #tabledata do

local isFiltered = false
–filterText = inputsearch
filterText = “a”

if( filterText ~= “” ) then – Don’t filter if filterText is empty.
if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then
isFiltered = false – Don’t filter this one out, we found the string.
–gvar=true
else
isFiltered = true – Filter it out, search term is not in the string.
– gvar=false

end
end
if( isFiltered == false) then
searchCount = searchCount + 1
searchtable[searchCount] = v
end
end
[/lua]
[import]uid: 93133 topic_id: 36095 reply_id: 143471[/import]

Thank you so much for the help. To anyone else who has had a similar issue, here is the code that ended up working for me:

for i,v in pairs(storedata) do  
  
 local isFiltered = false  
 filterText = inputsearch  
  
  
 if( filterText ~= "" ) then   
 if( string.find(string.lower( storedata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false   
 else  
 isFiltered = true   
 end  
 end  
 if( isFiltered == false) then   
 searchCount = searchCount + 1  
 searchtable[searchCount] = v  
 end  
 if( isFiltered == true) then  
  
 end  
 end  

Now, if I can get the native text fields to play nicely, I’ll be golden! Again, thank you so much for the help. [import]uid: 77043 topic_id: 36095 reply_id: 143492[/import]

If I understand what you’re doing, why not make a new table of data that only has the records in it that you searched for then load that table which is a subset of the data in to the tableView? [import]uid: 199310 topic_id: 36095 reply_id: 143406[/import]

hey, thanks for replying.

Tried taking your advice, but can’t seem to get it to work. See anything glaring?

for i=1, #tabledata do  
  
  
 local isFiltered = false  
 --filterText = inputsearch  
 filterText = "a"  
  
 if( filterText ~= "" ) then -- Don't filter if filterText is empty.  
 if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false -- Don't filter this one out, we found the string.  
 --gvar=true  
 else  
 isFiltered = true -- Filter it out, search term is not in the string.  
 -- gvar=false  
  
 end  
 end  
 if( isFiltered == false) then   
 searchtable[i] = v  
 end  
 end  
  

(got a little disjointed in the cut and paste, edited to try to clean up the lines) [import]uid: 77043 topic_id: 36095 reply_id: 143423[/import]

After a quick glance, perhaps this could solve the problem:

[lua]

local searchCount = 0

for i=1, #tabledata do

local isFiltered = false
–filterText = inputsearch
filterText = “a”

if( filterText ~= “” ) then – Don’t filter if filterText is empty.
if( string.find(string.lower( tabledata[i].title ) , string.lower( filterText )) ) then
isFiltered = false – Don’t filter this one out, we found the string.
–gvar=true
else
isFiltered = true – Filter it out, search term is not in the string.
– gvar=false

end
end
if( isFiltered == false) then
searchCount = searchCount + 1
searchtable[searchCount] = v
end
end
[/lua]
[import]uid: 93133 topic_id: 36095 reply_id: 143471[/import]

Thank you so much for the help. To anyone else who has had a similar issue, here is the code that ended up working for me:

for i,v in pairs(storedata) do  
  
 local isFiltered = false  
 filterText = inputsearch  
  
  
 if( filterText ~= "" ) then   
 if( string.find(string.lower( storedata[i].title ) , string.lower( filterText )) ) then   
 isFiltered = false   
 else  
 isFiltered = true   
 end  
 end  
 if( isFiltered == false) then   
 searchCount = searchCount + 1  
 searchtable[searchCount] = v  
 end  
 if( isFiltered == true) then  
  
 end  
 end  

Now, if I can get the native text fields to play nicely, I’ll be golden! Again, thank you so much for the help. [import]uid: 77043 topic_id: 36095 reply_id: 143492[/import]