Our Blog

Following a previous post about filtering records "as you type", we made an extended version. In this example, instead of filtering a list, we are filtering a grid and records are narrowed to those matching the text entered in the text input. What's different here is that we can choose the column on which we are filtering.

The code:

<cfsavecontent variable="actionFilter">
   if(_global.arrMembers == undefined) _global.arrMembers = data.dataProvider.slice(0);
   var arrMembers = _global.arrMembers;
   var arrDisplay:Array = [];
   var fortext = forInput.text.toLowerCase();
   var selected = column.selectedItem.data;

   for(var i = 0; i < arrMembers.length; i++)
   {
      if(arrMembers[i][selected].substr(0,fortext.length).toLowerCase() == fortext)
      {
         arrDisplay.push(arrMembers[i]);
      }
   }
   data.dataProvider = arrDisplay;
</cfsavecontent>

<cfform name="myForm" format="flash" width="400" height="300">
   <cfformgroup type="panel" label="Search our Members">
      <cfformgroup type="horizontal">
         <cfinput type="text" name="forInput" width="120" onchange="#actionFilter#" label="Filter by:">
         <cfselect name="column" label="in:" onchange="forInput.text=''" width="90">
            <option value="name">Name</option>
            <option value="gender">Gender</option>
            <option value="age">Age</option>
         </cfselect>
      </cfformgroup>
      <cfgrid name= "data" query="memberList" height="200"
rowheaders="false">

         <cfgridcolumn name="name" header="Name">
         <cfgridcolumn name="gender" header="Gender">
         <cfgridcolumn name="age" header="Age">
      </cfgrid>

   </cfformgroup>
</cfform>

View example.
Download source.

Update: We made an updated version of this code that uses a cfformitem type="script" (the preferred method now) instead

Nahuel Foronda

Nahuel Foronda

73 Comments

  1. Steve Walker
    Thank You! You have provided a wonderful tool for helping those of us that are not so AS savvy. I implemented your code on my soccer club website http://www.epicsoccer.org/fields.cfm.
  2. John
    If you were to substitute a &lt;cfquery&gt; for the &lt;cfscript&gt; code. Should this work as is ?
    I am having no luck with it.
  3. Laura
    John,
    It should work as is as long as you have a query named &quot;memberList&quot; with columns: id, name, age, gender.
    Otherwise, you will need to change the corresponding query name in the cfgrid tag, change the name of the cfgrid columns to those in your query and the option values in the cfselect also to match your columns.
  4. John
    Laura,

    I swapped out the &lt;cfscript&gt; block for the &lt;cfquery&gt; that follows below, but no luck.
    The grid is populated, however the filter blanks it out when it should return some rows.

    &lt;cfquery name=&quot;memberList&quot; datasource=&quot;your_datasource&quot;&gt;
    select
    1 as id,
    'Joe' as name,
    '25' as age,
    'Male' as gender
    from dual
    union
    select
    2 as id,
    'Jane' as name,
    '35' as age,
    'Female' as gender
    from dual
    union
    select
    3 as id,
    'Henry' as name,
    '50' as age,
    'Male' as gender
    from dual
    union
    select
    4 as id,
    'Alice' as name,
    '55' as age,
    'Female' as gender
    from dual
    union
    select
    6 as id,
    'Cindy' as name,
    '25' as age,
    'Female' as gender
    from dual
    &lt;/cfquery&gt;

    Thanks for your help. John
  5. John
    Laura,

    I found the answer to the problem I was having when I used a &lt;cfquery&gt; (oracle db). The column names returned by the oracle query are uppercase, unless they are in quotes, therefore the actionscript was not finding any matches. Below is my fix.

    var selected = column.selectedItem.data.toUpperCase();

    Or you could quote the column names in the query.

    select
    1 as &quot;id&quot;,
    'Joe' as &quot;name&quot;,
    '25' as &quot;age&quot;,
    'Male' as &quot;gender&quot;
    from dual
    union
    select
    2 as &quot;id&quot;,
    'Jane' as &quot;name&quot;,
    '35' as &quot;age&quot;,
    'Female' as &quot;gender&quot;
    from dual
    etc...

    John
  6. Pedro
    I love this!

    The only way it could be better is if you could filter on any part of the record (rather than the first character). I know being able to type 'an' and return 'Alan' along with 'Ann' and 'Annie' might seem silly in this implementation but I can see many time when this would be helpful.

    If only I had the talent to modify the code to do this.

    Good work!
  7. Jason
    I have added a checkbox to my grid when implementing this solution, when i use the filtering functionality and submit my form the arrays are empty on the submitting page...things work correctly when the filtering functionality is not used though...is there an issue with re-binding the data to a grid and trying to determine which values have been changed?
  8. Casey
    Am I missing something? I am running CFMX 7. I took this .cfm file and copied it into my localhost directory. I cannot see anything, it does nothing for me. It looks cool on your site, but on my localhost, nothing! Please help, I need this functionality to finish up a huge project I am working on. I made no changes to the file, just took your copy.
  9. Steve Walker
    Is there any way to filter the filtered data? (Using your example, first I filter by name then by age.) Thanks for even considering it.
  10. Nahuel
    Hi Jason,
    To do that you may change my code and use the function GridData.insertRow(gridName)
    GridData.deleteRow(gridName)
    To update the grid. And you will get what was changed when you submit the form.

    Steve,
    That is possible but you need to maintain multiples copies of the data to keep track of your filtering.

    Casey,
    Does any other flash form work for you? If not, and assuming you are on Windows, check the installation and whether you have a virtual directory for cfide and jRunScripts (needed for remoting). You can run the web server connectors to set it up.
  11. chris
    you just saved my day with this here. had a problem filtering the grid because of the AS keywords new, import ect. now it works fine filtering. thanks!
  12. Brendan Ganning

    Brendan Ganning

    How would you change the substring function so that you could filter on any part of the record. an would return Alan, Jane or Brendan depending on the query. Is there an actionscript find function or something I could use to substitue?
  13. Brendan Ganning
    I have included my snippet of code that allows for searching over all parts of the record, not just the first part. Ex. Search on O would return Joe, Oliver etc. However, when a user hits backspace, the filter continues to work correctly except the records in the grid are repeated. example can be found: cf7test.aciwebs.com/brendan/test.cfm

    Anyone know how to fix this?

    &lt;cfsavecontent variable=&quot;actionFilter&quot;&gt;
       if(_global.arrRecipes == undefined) _global.arrRecipes = data.dataProvider.slice(0);
       var arrRecipes = _global.arrRecipes;
       var arrDisplay:Array = [];
       var fortext = forInput.text.toLowerCase();
       var selected = column.selectedItem.data;
       
       for(var i = 0; i &lt; arrRecipes.length; i++)
       {
          for(var x = 0; x &lt; arrRecipes[i][selected].length; x++){
             if(arrRecipes[i][selected].substr(x,fortext.length).toLowerCase() == fortext)
             {
                arrDisplay.push(arrRecipes[i]);
             }
          }
       }
       
       data.dataProvider = arrDisplay;
    &lt;/cfsavecontent&gt;
  14. Brendan Ganning
    Ok I have it working so that you can sort on any part of the string and when the user deletes part it will not duplicate the records. The only difference was a break; was needed after the arrDisplay push:

    for(var i = 0; i &lt; arrRecipes.length; i++)
    {
    for(var x = 0; x &lt; arrRecipes[i][selected].length; x++){
    if(arrRecipes[i][selected].substr(x,fortext.length).toLowerCase() == fortext)
    {
    arrDisplay.push(arrRecipes[i]);
    break;
    }
    }
    }

    This may be too slow with large recordsets, but with small ones it will work well.
  15. Charles-Henry Vespierre

    Charles-Henry Vespierre

    Two thumbs up !! Amazing work !! Bookmarks =)
    I would like to know how reset my filtered datagrid to get all my data again. i ve added a button but which command have i to use ?

    Thanks so much

    And keep going!!
  16. Nahuel
    Hi, Charles
    To do that you can add this line of code in the onClick of your button:
    data.dataProvider = _global.arrMembers;
  17. Raphael Anzenberger
    Nahuel,

    Very fine job that you have done here. Thanks for sharing it with the CF community.
    This question is relative to Jason's comment on the fact that, when submitted, the form diplays empty arrays if the filter is used. You have suggested the use of GridData.insertRow(gridName)
    GridData.deleteRow(gridName). Could you please give us a working example of this, if time allows of course?

    Many thanks again,

    Raphael Anzenberger,
    Michelin Tire Corp. North America.
  18. Nahuel
    Hi,
    For all of you that want to get an Array with the removed items (instead of an empty array), you can replace the actionFilter function with this one:
    &lt;cfsavecontent variable=&quot;actionFilter&quot;&gt;
       if(_global.arrMembers == undefined) _global.arrMembers = data.dataProvider.slice(0);
       else data.dataProvider = _global.arrMembers.slice(0);
       var fortext = forInput.text.toLowerCase();
       var selected = column.selectedItem.data;
       var i = 0;   
       
       while(i &lt; data.dataProvider.length)
       {
          if(data.dataProvider[i][selected].substr(0,fortext.length).toLowerCase() == fortext)
          {
             i++;
          }
          else
          {
             data.selectedIndex = i;
             GridData.deleteRow(data);
             data.selectedIndex = undefined;
          }
       }

    &lt;/cfsavecontent&gt;
    I don't know exactly what is what you want to achieve. I think that this code might help you to start.
  19. Raphael Anzenberger
    Nahuel,

    Thanks for taking the time to respond to this query. I wanted to clarify the comment I made, and I will use an example to illustrate. I have a grid which holds the name of n people. When I use the filter, using department = IT for instance, the grid returns 2 rows. When I submit the form, the action page does not return the names of these 2 people, ie the returned array for the form is empty.
    The code you posted returns the names of the people who were deleted; I think that what Jason and I had in mind, was for the grid to return the names of the people who were &quot;filtered&quot;, ie the 2 rows in the given example above.

    Sorry to take some much comment space on your blog. Thank you for re-considering this query, again, if your time allows.

    Raphael Anzenberger.
  20. Raphael Anzenberger
    Nahuel,

    I must add the following to the above comment:
    This is true only if the following scenario is true:
    - if the cfform contains the attribute selectmode=&quot;edit&quot;, and the user modifies the record, the returned array for FORM is empty when the filter is used.
    - if this attribute is not added and the user selects a row, the form returns the data from the row correctly.

    Raphael Anzenberger.
  21. Christian Russo

    Christian Russo

    I'm having a similar, but somwhat different problem. I have my grid columns bound to various text inputs which users can modify. Upon being submitted, I call a cfgridupdate which updates the column data, if there were any changes. However, when I filter and then make changes, they are not saved after submitting. Can anyone help me out here? Thanks in advance.
  22. Nahuel
    Hi Raphael,
    The problem is that the Array created has only the items that have changed. Those 2 rows that you mention are the items that haven't changed. To do what you want, maybe you could start with an empty dataProvider and insert two new items with the method GridData.insertRow(gridName) and copy the filtered data in these new rows. In this way, the array will have only two rows with the filtered data. But, IMHO, it's to much work to do that. Maybe you could do this on the server instead ( I don't know, I'm just throwing some ideas)

    __________________________________________

    Christian,
    I'll see if I can do an example regarding your question
  23. Nahuel
    OK, I made some changes to the code to keep the edited records. This is something that Christian and others requested :)

    You need to replace the actionFilter with this new code:

    &lt;cfsavecontent variable=&quot;actionFilter&quot;&gt;
       if(_global.arrMembers == undefined) _global.arrMembers = data.dataProvider.slice(0);
       var arrMembers = _global.arrMembers;
       var arrDisplay:Array = [];
       var fortext = forInput.text.toLowerCase();
       var selected = column.selectedItem.data;
       var i = 0;
       var n = 0;
       data.dataProvider.sortOn(&quot;CFGRIDROWINDEX&quot;);
       
       
       while(i &lt; arrMembers.length)
       {
          var item;
          if(data.dataProvider[n].CFGRIDROWINDEX == n - 1)
          {
             item = data.dataProvider[n++];
          }
          else
          {
             item = arrMembers[i];
          }
          if(item[selected].substr(0,fortext.length).toLowerCase() == fortext)
          {
             arrDisplay.push(item);
          }
          i++
       }
       data.dataProvider = arrDisplay;
    &lt;/cfsavecontent&gt;
  24. Felipe
    Nahuel, I have that same problem.
    But this fix is not working it steel giving me empty arrays on the form and it got back to only search in the first part of the record.
  25. Felipe
    Just to show the problem, put a &lt;cfdump var=&quot;#form#&quot;&gt; on the submit page and you will see that when you make any change without filtering cf makes an array with the changes, but if you filter and than make changes it throws empty arrays insted.
  26. The Scarecrow

    The Scarecrow

    I have modified your example a bit and done the following:

    I removed the select list from the filter and just filter on last name in my example. The select list basically became a seperate filter to filter on department of the person.

    I also have a number of cfinput text that have a bind to the grid.

    My problem is that if a grid item is selected, the text fields are filled. But if a new filter is applied to the grid the text fields all display &quot;undefined&quot; (which is expected) but how can I set it to an empty string if it is undefined ?
  27. Nahuel
    Hi Scarecrow.
    You can check that with something like this:
    {( myGrid.selectedItem == undefined ) ? &quot;&quot; : myGrid.selectedItem;}
  28. Scarecrow

    Scarecrow

    Thank you Nahuel,

    Work like a charm, I gues you can't use

    if(blah) do this else this

    in the bind
  29. IdaChen

    IdaChen

    I tried to modify and apply this tool to my application but got problems. Instead of using grid or listbox, I used checkboxes so that users can multi-select the items. I then trimmed out the prefix to get appIDs for further use. Shown as below:

    &lt;cfloop query=&quot;listMBAa&quot;&gt;
    &lt;cfinput type=&quot;checkbox&quot; name=&quot;boxMBAa_#appID#&quot; label=&quot;#fullName#&quot;&gt;
    &lt;/cfloop&gt;   

    Is there anyway to filter through the list of checkboxes like it does with the grid? Thanks a lot
  30. IdaChen

    IdaChen

    I tried to modify and apply this tool to my application but got problems. Instead of using grid or listbox, I used checkboxes so that users can multi-select the items. I then trimmed out the prefix to get appIDs for further use. Shown as below:

    &lt;cfloop query=&quot;listMBAa&quot;&gt;
    &lt;cfinput type=&quot;checkbox&quot; name=&quot;boxMBAa_#appID#&quot; label=&quot;#fullName#&quot;&gt;
    &lt;/cfloop&gt;   

    Is there anyway to filter through the list of checkboxes like it does with the grid? Thanks a lot
  31. IdaChen

    IdaChen

    I tried to modify and apply this tool to my application but got problems. Instead of using grid or listbox, I used checkboxes so that users can multi-select the items. I then trimmed out the prefix to get appIDs for further use. Shown as below:

    &lt;cfloop query=&quot;listMBAa&quot;&gt;
    &lt;cfinput type=&quot;checkbox&quot; name=&quot;boxMBAa_#appID#&quot; label=&quot;#fullName#&quot;&gt;
    &lt;/cfloop&gt;   

    Is there anyway to filter through the list of checkboxes like it does with the grid? Thanks a lot
  32. IdaChen

    IdaChen

    I tried to modify and apply this tool to my application but got problems. Instead of using grid or listbox, I used checkboxes so that users can multi-select the items. I then trimmed out the prefix to get appIDs for further use. Shown as below:

    &lt;cfloop query=&quot;listMBAa&quot;&gt;
    &lt;cfinput type=&quot;checkbox&quot; name=&quot;boxMBAa_#appID#&quot; label=&quot;#fullName#&quot;&gt;
    &lt;/cfloop&gt;   

    Is there anyway to filter through the list of checkboxes like it does with the grid? Thanks a lot
  33. Hi,
    I made a new example that shows how to do the same but using an editable grid.
    http://www.asfusion.com/blog/entry/filtering-a-cfgrid-as-you-type--revisited-
  34. diana
    How do you update and delete records to the database?
  35. Michael White

    Michael White

    When I adapt this ActionScript to my page that uses a grid populated by a Component function, I get a compile error saying there is no data method
  36. Michael White

    Michael White

    I figured out my problem: you named your grid &quot;data&quot; and in the actionscript I thought that the word data was a keyword or part of the command ('cause I'm ignorant). I replaced 'data' with the name of my grid and I'm fine.
  37. michael White

    michael White

    I love this routine, I use it all the time now. In fact I have three grids on a page with two of these routines to filter the top two grids and the third grid is filtered by the first grid. I had to rename forInput to forInput1 and forInput2, rename column to column1 and column 2, and then rename the arrays to arr1 and arr2 but it works great. Then I submit the form and process using the selected items on each grid... do you guys have an Amazon wish list we could use to repay you for all your great work? (ala Ray Camden)
  38. Hi Michael,
    Thanks for your interest, actually we have a wish list in our about page: http://www.asfusion.com/blog/about
  39. mafdoc
    michael??
    I've tried to change everything. Either the cfform doesn't load or the filter doesn't work.
    I get the data but when I type into the field all the data disappears. I think it's the var selected. Please help...

    &lt;cfsavecontent variable=&quot;invFilter&quot;&gt;
    if(_global.arr1Members == undefined) _global.arr1Members = invgrid.dataProvider.slice(0);
    var arr1Members = _global.arr1Members;
    var arr1Display:Array = [];
    var fortext1 = forMyInput.text.toLowerCase();
    var selected = invcolumn.selectedItem.invgrid;

    for(var i = 0; i &lt; arr1Members.length; i++)
    {if(arr1Members[i][selected].toString().substr(0,fortext1.length).toLowerCase() == fortext1)
    {arr1Display.push(arr1Members[i]); } }
    invgrid.dataProvider = arr1Display;
    &lt;/cfsavecontent&gt;

    cfinput name=&quot;forMyInput&quot; onChange=&quot;#invFilter#&quot;
    cfselect name=&quot;invcolumn&quot; onChange=&quot;forMyInput.text=''&quot;
    cfgrid name=&quot;invgrid&quot;

    I don't have any experience with AS.
    Thanks for any help.
  40. mafdoc
    It's the grid name that seems to make the filter fail. Now how do you have two filters with the same cfgrid name=&quot;data&quot; The cfform doesn't load.
  41. Hi mafdoc,
    Try to change
    var selected = invcolumn.selectedItem.invgrid;
    to
    var selected = invcolumn.selectedItem.data;
    Let me know if that works
  42. mafdoc
    I'm sorry Nahuel, This did work. I got the answer from luara on another blog.
    Thanks for your help though.
  43. Michele

    Michele

    In case anyone is trying to do the same thing...

    I used the filtering records on a cfform grid example to filter my records by active, inactive or all records. Then I wanted to be able to filter that recordset by searching for a specific string in a specified column (as this example does). Since both examples use the same cfsavecontent tag with minor differences, I was able to combine the solutions and it seems to be working perfectly.

    Here's the modified cfsavecontent tag:

    &lt;cfsavecontent variable=&quot;filterGrid&quot;&gt;
       if(_global.arrClinics == undefined) _global.arrClinics = data.dataProvider.slice(0);
       
       var arrClinics = _global.arrClinics;
       var arrDisplay:Array = [];
       var fortext = forInput.text.toLowerCase();
       var selected = column.selectedItem.data;

       for(var i = 0; i &lt; arrClinics.length; i++)
        {
          if(arrClinics[i].Status == status.value || status.value == 'All')
          {
             if(arrClinics[i][selected].toString().substr(0,fortext.length).toLowerCase() == fortext)
             {
             arrDisplay.push(arrClinics[i]);
             }
          }
       }
       data.dataProvider = arrDisplay;
    &lt;/cfsavecontent&gt;

    The references to &quot;Clinics&quot; and &quot;Status&quot; are specific to my project, so you would change them.

    Another note. I changed the order of the fields in the text input search. So it goes Look in: (cfselect) for: (text input). I think this is more intuitive because if the user changes the cfselect the text field is cleared.

    Happy coding everyone and thank you, thank you, thank you Laura &amp; Nahuel!
  44. Isidro
    Thank you this works extremly well. But I am having a small problem. If you could share some insight on what could possibly be causing my problem that would be great? I am querying LDAP and it only returns 500 rows and there are about 1700 rows. Do you have any ideas as to way? Thanks in advanced for your assitance.
  45. Dan Lavender
    Hi there,

    I've been having trouble with the following line in these cfgrid tutorials:

    if(_global.arrMembers == undefined) _global.arrMembers = data.dataProvider.slice(0);

    I've been creating an FAQ page where you select the question and the answer appears in a

    TextArea. The cfgrid is called &quot;questions&quot; and has the columns &quot;Question&quot; and &quot;Category&quot;. So my

    original code based on the above was:

    if(_global.arrMembers == undefined) _global.arrMembers = questions.dataProvider.slice(0);

    It didn't set _global.arrMembers because questions.dataProvider.slice(0) didn't appear to do

    anything!?

    I got around this by altering the code in a couple of areas. First I created _global.arrMembers

    by looping through dataProvider and adding the values to a temporary array like so:

    if(_global.arrMembers == undefined){
       var tempArray:Array = [];
       for(var i=0;i&lt;data.dataProvider.length;i++){ //&gt; this hides the DW errors!
          tempArray.push(data.dataProvider.getItemAt(i));
                
       }
       _global.arrMembers = tempArray;
    }

    Then I changed the IF statement that populates arrDisplay to this:

    if(arrMembers[i].Question.substr(0,keywordText.length).toLowerCase().indexOf(keywordText.toLower

    Case()) != -1)

    Notice &quot;Question&quot; is the name of the cfgrid column

    Don't know why the original code didn't work - great blog though!
  46. In regards to the post about having the undefined fields after doing another filter, you mentioned using this code:

    {( myGrid.selectedItem == undefined ) ? &quot;&quot; : myGrid.selectedItem;}

    Can you please give a more detailed example.

    Thank you.
  47. This does not seem to work on a query that returns a numeric column. flitering works for string columns just fine. Any advice?

    Thanks a lot.
  48. Laura
    Alex,
    add .toString() before every .toLowerCase()
    I would recommend to use the updated version of this example:

    http://www.asfusion.com/blog/entry/filtering-a-grid-as-you-type---using
  49. Aleii
    Just a quick thank you - I put the code in, changed the gridname and it worked right away.
    Love it!!!
  50. George Lu
    Re: Steve Walker's Comment (first one).

    Hi Steve,

    I've looked your website (http://www.epicsoccer.org/fields.cfm) and it looks exactly what I want. Could you please tell me how did you do that (i.e. select a row from the grid and popular data below as form fields)?

    Thanks,
    George
  51. Laura
    George,
    See this example and accompanying article:
    http://www.asfusion.com/blog/entry/coldfusion-flash-forms-cfdj-article
  52. George Lu
    Hi Laura,

    Thank you again for helping me. I've implemented the edit fields for cfgrid as the example shown but this only allow to put one drop down box. I can't add a second drop down box for editing. Please help.

    PS. this article is part I and the edit part will be in part II. Where can I find the part II?

    Thanks,
    George
  53. George Lu
    Hi Laura,

    I've found part II but still can't get second drop down box works. Since I have got filtering a grid as well I can't change flash remoting to the one in example.

    George
  54. Pedro
    How would I count the amount of filtered results. For example, if I start out with 200 grid rows, then filter it down to 25, how could I display that in the panel label?

    Great site, it has been EXTREMELY helpful!!

    Pedro
  55. Laura
    Pedro,
    You can use the variable myGridName.dataProvider.length. If you use it as a label, then you would do something like:
    <cfformgroup type="panel" label="Records found: {myGridName.dataProvider.length}">
  56. Jackson
    I’m newer to CF from a different technology. I really like it. I found this example to be exactly what I need to do for an internal app we’re converting. This example works great when I copy it to are test server. Here’s what I’m not getting to work.

    I want to be able to return all of the rows from a certain SQL dbo:

    dbo. TABLENAME_content01

    There are usually less than 80 rows in this table, but they change every evening. Here are my two problems.

    Problem 1:

    How do I get this example to return all of the rows in that database?

    Problem 2:

    How do make the rows clickable (drill down) to an edit page that reads a string variable that I pass from the row I click?

    This is how I perform this funcion now (non-flash CFGRID):

    <table border="1" cellpadding="1" cellspacing="1">
    <tr>
    <td>Last Name</td>
    <td>First Name</td>
    <td>Phone Number</td>
    <td>eMail Address</td>
    </tr>
    <cfoutput query="allcontent01">
    <tr>
    <td><a href="Main-List-content1a-edit.cfm?PERSONId=#allcontent01.PERSONId#">#allcontent01.PERSONLASTNAME#</a></td>
        <td># allcontent01.PERSONFIRSTNAME#</td>
    <td># allcontent01.PERSONCOPHONE#</td>
    <td># allcontent01.PERSONEMAILADDRESS#</td>
    </tr>
    </cfoutput>

    I prefer the flash CFGRID concept, and would like to get this working. You are all so helpful, please provide guidance…

    Thanks!
  57. Landry

    Landry

    I can never get onClick="GridData.insertRow(myGrid);" to work. I am getting a javascript error of "GridData undefined." Anyone got a clue why this is happening?
  58. michael white
    If it's a flash form, maybe using braces?
    onClick="{GridData.insertRow(myGrid);}" because it's actionscript, not javascript? You have a cfformitem type="script" I assume?.
  59. Landry

    Landry

    This is what I have and it throws an error in IE or FF. I tried both flash and the applet. (can't get the maxRows to work either)

    <tr><td colspan="2">
    <cfgrid name="VendorGrid" height="140" width="750" query="Transact" rowheaders="false"
       autowidth="true" selectmode="edit" insert="yes" format="applet" delete="yes">
       <cfgridcolumn name="Account" header="Account">
       ...
    </cfgrid>
    </td></tr>
    <tr><td colspan="2">
       <cfinput type="button" name="Submit7" value="Insert" onClick="GridData.insertRow(VendorGrid);">
    </td></tr>
  60. seefor
    This is my current code works great but plain looking:

    <cfquery name="NG_Switches" datasource="siffer">
    SELECT *
    FROM dbo.ATM_IP
    WHERE fabric_name like 'NG-%'
    ORDER BY dbo.ATM_IP.fabric_name ASC
    </cfquery>

    <cfquery name="SD_Switches" datasource="siffer">
    SELECT *
    FROM dbo.ATM_IP
    WHERE fabric_name not like 'NG-%' AND switch_type not like 'Ci%' AND switch_type not like 'On%'
    ORDER BY dbo.ATM_IP.fabric_name ASC
    </cfquery>


    <InvalidTag type="text/javascript">
    function go(where){window.location.href=where;}
    </script>



    <div id="ctr" align="center">
    <div class="login">
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td align="center" colspan="2" >Telnet</td>
    </tr>
    <tr>
    <td> <select name="Menu" onChange="go(this.value)">
    <option>NG ATM Switch</option>
    <cfoutput query="NG_Switches">
    <option value="telnet://#NG_Switches.ip_address#">#NG_Switches.fabric_name#</option>
    </cfoutput>
    </select></td>
    <td> <select name="Menu" onChange="go(this.value)">
    <option>SD ATM Switch</option>
    <cfoutput query="SD_Switches">
    <option value="telnet://#SD_Switches.ip_address#">#SD_Switches.fabric_name#</option>
    </cfoutput>
    </select></td>
    </tr>

    <tr>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td align="center" colspan="2" >HTTP</td>

    </tr>
    <tr>
    <td><select name="Menu" onChange="go(this.value)">
    <option>HD ATM Switch</option>
    <cfoutput query="NG_Switches">
    <option value="http://#NG_Switches.ip_address#">#NG_Switches.fabric_name#</option>
    </cfoutput>
    </select></td>
    <td> <select name="Menu" onChange="go(this.value)">
    <option>SD ATM Switch</option>
    <cfoutput query="SD_Switches">
    <option value="http://#SD_Switches.ip_address#">#SD_Switches.fabric_name#</option>
    </cfoutput>
    </select></td>
    </tr>

    </table>
    <div class="clr"></div>
    </div>
    </div>

    </div>



    <br><br>



    This is the new code(make it look better) I'm trying to write with the same affects:

    <cfquery name="NG_Switches" datasource="siffer">
    SELECT *
    FROM dbo.ATM_IP
    WHERE fabric_name like 'NG-%'
    ORDER BY dbo.ATM_IP.fabric_name ASC
    </cfquery>

    <cfquery name="SD_Switches" datasource="siffer">
    SELECT *
    FROM dbo.ATM_IP
    WHERE fabric_name not like 'NG-%' AND switch_type not like 'Ci%' AND switch_type not like 'On%'
    ORDER BY dbo.ATM_IP.fabric_name ASC
    </cfquery>


    <cfform name="myForm" format="flash" width="500" height="650">
    <cfformgroup type="panel" label="Search our markets" height="250">
    <cfselect query="NG_Switches" queryposition="below" group="fabric_name" label="State" name="myselect1" value="ip_address" display="fabric_name" width="200" >
    <option value="All">All</option>
    </cfselect>
    <cfgrid appendkey="yes" name="data" query="NG_Switches" href="telnet://ip_address" hrefkey="ip_address" selectmode="single" >
    <cfgridcolumn header="Fabric" name="fabric_name" />
    <cfgridcolumn header="IP Address" name="ip_address" />
    <cfgridcolumn header="Switch Type" name="switch_type" />
    <cfgridcolumn header="id" name="id" display="false" />

    </cfgrid>
    </cfformgroup>
    </cfform>


    Problem is when I click on the row or IP address it does not open up a telnet session to the ip address.

    I Google cfgrid url and cfgridcolumn url found some basic examples and that's what I tried above.

    I hope some one can help Smile or point me in the right direction.

    Thanks in advance
  61. Harold
    I would like to be able to filter by more than one field in the drop down list and more than one text input at the same time.

    Example:
    (1)First name field from drop down list, Text input: A
    (2)Last name field from drop down list, Text input: B
    (3)State field from drop down list, Text input: C

    If anyone can help me with this ASAP it would save my neck.
  62. Harold
    I would like to be able to filter by more than one field in the drop down list and more than one text input at the same time.

    Example:
    (1)First name field from drop down list, Text input: A
    (2)Last name field from drop down list, Text input: B
    (3)State field from drop down list, Text input: C

    If anyone can help me with this ASAP it would save my neck.
  63. Darkenning
    Hi all,

    I would like to find a way to search each column of the grid when entering text into the filter box rather than one coulmn at a time - is this possible?

    Many thanks for your help in advance!
  64. Royal T

    Royal T

    I am looking to filter the results based on select options only. Anyone have code for that?
  65. Royal T

    Royal T

    I am looking to filter the results based on select options only. Anyone have code for that?
  66. Troy
    IS there a way to filter multiple columns through one
    <option value="">

    i.e. I would like to be able to use this to search through 3 columns

    I have tried several combinations and have been unsuccessful, but my AS3 is very beginner
  67. Troy
    IS there a way to filter multiple columns through one
    <option value="">

    i.e. I would like to be able to use this to search through 3 columns

    I have tried several combinations and have been unsuccessful, but my AS3 is very beginner
  68. kimosabe

    kimosabe

    How do you use colspan in cfgrid? What is the substitute for it?
  69. kimosabe

    kimosabe

    How do you use colspan in cfgrid? What is the substitute for it?
  70. Axel
    Kimosabe,
    The CFGRID is a table in itself. You can specify pretty much everything there. As far as I know there is no colspan as an attribute to modify.

    Axel
  71. kimosabe

    kimosabe

    Axel,

    Thanks for your quick response. I used the width attribute. It is in pixcels. It is a little more work in cfgrid than html table but I think I got it.

    kimosabe
  72. FlashHack

    FlashHack

    For those attempting to use this method with a dataProvider that was a query returned via Flash Remoting, you will find that dataProvider.slice(0) will not work. Instead you should implement a version that utilizes the methods of the Flash Remoting Recordset object (http://livedocs.adobe.com/flashremoting/mx/Using_Flash_Remoting_MX/UseASData6.htm). Check out the RecordSet.filter method.