Hello, i thought i'd do this question in tutorial style. So it's at least helpful to others..
I want to search through my datagrid to filter the content that matches a TextBox. I am currently making it so that you can use a combox to select which field you want to search through, but will post that code once it's complete.
I have a datagrid loaded from xml content (which was taken from mysql). This content (Dataprovider) is called 'acOrder'
This is my textbox and a search button. The button calls the function 'doFilter' in my AS script
<mx:TextInput id="filterTxt" width="238" toolTip="Search by status"/>
<mx:Button id="filterButton" icon="@Embed('icons/SearchRecord.png')" toolTip="Search:" click="filtercontent()"/>
This is the AS script functions:
private function filterColumn(item:Object):Boolean
{
var content:String = filterTxt.text
var key:String = item.orderid
if(content.indexOf(key) !=-1)
{
return true;
}
else
{
return false;
}
}
///if the textbox is empty, it then calls back all of the data. I actually use a 'reset' button to do this as well.
private function filtercontent():void
{
if (filterTxt.text.length == 0)
{
acOrder.filterFunction = null
}
else
{
acOrder.filterFunction = filterColumn;
}
acOrder.refresh()
}So my question is, I have used indexOf to try to search so that only part of the string needs to match the Data. (as jorge showed in my as3 thread
http://www.flash-db.com/Board/index.php?topic=18735.0).
But why does it ONLY return 'true' on the data which matches the Entire string?
It should be returning each row which has just PART of the string in the textfield?