1 Reply Latest reply on Jun 23, 2006 2:33 PM by samdl1

    DataGrid filtering issues

      Hi all,
      I have been working on using a datagrid to display contacts loaded from PHP generated XML. Because of the number of contacts I need to be able to filter the contacts down by typing a name in a text box much like in Outlook or iTunes. I have created a function which listens for the text box changing in which I have used the indexOf() method to throw out unwanted values then reload the datagrid...Using a different method I managed to get it working but without refreshing the grid so values were just removed instead of the grid reloading and cynching up.

      This method doesnt really work but it does cause the grid to properly refresh so any advice would be greatly appreciated.

      //create temporary array
      var newdgarray_array:Array = new Array;

      //define filtertextchange object
      var filtertextchange:Object = new Object;
      filtertextchange.change = function(eventObject:Object) {

      //remove and redefine temp array to force the grid refresh
      delete newdgarray_array;
      var newdgarray_array:Array = new Array;

      //set temp array to same as original xml data
      newdgarray_array = clientdetails_array;

      var lctext:String = filtertext.text.toLowerCase();

      //2n multidimensional array so two for loops required
      for (var i in clientdetails_array) {
      for (var j in clientdetails_array ){
      var lc_checker = clientdetails_array
      if(lc_checker.indexOf(lctext) == -1)
      //chuck out non matching data using dataprovider API methods

      //cause the datagrid to reload new array data
      clientdetails.dataProvider = newdgarray_array;

      //listen for 'filtertext' textbox to change
      filtertext.addEventListener("change", filtertextchange);

      Thanks for reading,