Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 08:57
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  V2 Components (Flash MX 2004 - Flash 8) (Moderators: vesa kortelainen, Ronald Wernecke, Jorge Solis, ..:: Mazhar Hasan ::.., papachan)
| | |-+  Searching a dataset and displaying results in datagrid
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Searching a dataset and displaying results in datagrid  (Read 5368 times)
Nate Elston
Server what's that
*
Posts: 4



View Profile Email
« on: 02/11/05, 17:03 »

Hello All,
I am working to search a bunch of data in a dataset and display the results in a datagrid and I have been working on this for a while and I have come up with the following code:

//first empty the previous found set
foundset_ds.clear();
data1_ds.addSort("description", ["description", "trackID"]);
if(data1_ds.find(searchTerm)) {
foundset_ds.addItem(data1_ds(data1_ds.getItemId()));
}

And I have the datagrid bound to the 'foundset_ds'.

Am I missing anything?  I know the data is being read into data1_ds properly becuase it is displayed in another datagrid for debugging purposes.  Any help into getting this to work would be greatly apprecited, sorry I am a little light on the details if you need to know anything let me know.
Thanks
Nate
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #1 on: 02/12/05, 03:42 »

Since the find method set the searched term as the selected item, you can simply copy the row:

if(data1_ds.find(searchTerm)) {
  foundset_ds.addItem(data1_ds.currentItem);
}

Jorge
Logged

Nate Elston
Server what's that
*
Posts: 4



View Profile Email
« Reply #2 on: 02/14/05, 14:38 »

Thanks for your help.  But I have to be missing something because it is not working at all, I don't have any idea why it won't I have implemented the changes you said and I tried it with a while loop but still nothing.  Any other suggestions, do I have to refresh something else?
Thanks
Nate
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #3 on: 02/14/05, 17:37 »

Yep, there're some bugs in the dataset.find method, check http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_19362

A manual approach:

Drag a couple of dataset named "data1_ds" and "foundset_ds" plus a button (not a component) named "myButton". Use this code:

function search(searchTerm){
   for(var 
z in data1_ds.items)
   if(
data1_ds.items[z].Name==searchTerm){
      
trace("Match !!")
        
foundset_ds.addItem(data1_ds.items[z]);
   }
}
for(
i=0i<10i++) data1_ds.addItem({Name:"Name"+i})
listener = {}
listener.modelChanged = function (evt) {
  for(var 
i in evt.target.itemstrace(evt.target.items[i].Name)
}
foundset_ds.addEventListener("modelChanged"listener)
myButton.onPress = function(){
   
this._parent.search("Name5")
}

The foundset_ds dataset will store the searched term

Jorge
« Last Edit: 08/15/07, 02:28 by Jorge Solis » Logged

da288
Server what's that
*
Posts: 17


View Profile
« Reply #4 on: 08/14/07, 08:13 »

Your "searchTerms" must be in array format e.g.: dataset.find([var1]) or ["string1"] etc. That should help.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!