ColdFusion 8 Grid Filtering

Word Count: 206

Over the past couple of weeks I have been writing quick tutorials on extending the built in AJAX components. Today I would like to show you an example that I believe everyone is going to find useful. Once you have a data grid displaying your data there are usually 2 key operations users will perform. The 1st is pagination of records which is built into the grid and is pretty easy to use. The 2nd is filtering or how can I find exactly what I am looking for without browsing all of the records. Most filter examples I have seen where built outside of the grid but I want to run through an example that builds a filter into the grid.

Before we get started I think we should take a look at the outcome, this way the tutorial makes a little more sense. I do not have 8 running so I will have to explain this using pictures. First we have a list of artists and I provide the user a way to filter the artists by what state they are in. When the state is selected the grid is updated.

This demo like the others uses the cfartgallery data source that ships with CF so you should be able to run this example without any setup. The first thing we need to do is run our query and display our grid. This is pretty basic and you should understand what is going on here.

<cfquery name="getArtists" datasource="cfartgallery">
   SELECT artistId, firstname, lastname, address, city, state, postalcode, email
   FROM Artists
   </cfquery>
   
   <cfset args = structNew()>
   <cfset args.name = "ArtistGrid">
   <cfset args.format = "html">
   <cfset args.query = "getArtists">
   <cfset args.stripeRows = true>
   <cfset args.selectColor = "##D9E8FB">
   <cfset args.width = 600>
   
   <cfform>
      <cfgrid attributeCollection="#args#">
         <cfgridcolumn name="artistid" display="false">
         <cfgridcolumn name="firstname" header="First Name">
         <cfgridcolumn name="lastname" header="Last Name">
         <cfgridcolumn name="email" header="Email Address">
         <cfgridcolumn name="address" header="Address">
         <cfgridcolumn name="city" header="City">
         <cfgridcolumn name="state" header="State">
         <cfgridcolumn name="postalcode" header="Zip">
      </cfgrid>
   </cfform>
Now that our grid is setup we need to call a function post setup. We can do this using the ajaxOnLoad tag.
<cfset ajaxOnLoad("init")>
I am going to be using some toolbar and button code that is a part of the Ext framework. To make use of those classes we must import them.
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/toolbar/toolbar.js"></script>   
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/button/button.js"></script>
Now that we setup our init method that will automatically get called after the page is setup. We need to get the grid component and we can use the built in method to do so. Next if you read my custom toolbar article you know the next couple of lines grabs the header panel and creates a toolbar on it.
<script type="text/javascript">
function init(){
      grid = ColdFusion.Grid.getGridObject("ArtistGrid");
      var gridHead = grid.getView().getHeaderPanel(true);
      var tbar = new Ext.Toolbar(gridHead);
      
}

</script>
Now we need to build our combo box that will be used as a filter. If you are not familiar with Ext you may want to look at the docs. A Combo box can loaded using json but for this example to keep things simple I am just going to load the box inline. The empty text attribute the text to display in the box while now selection is made.
cb = new Ext.form.ComboBox({
   id:"stateFilter",
   emptyText:"Filter By State",
   mode:"local",
   triggerAction:"all",
   displayField:"text",
   valueField:"value",
         store:new Ext.data.SimpleStore({
            fields: ["value", "text"],
            data: [
               ["CA","California"],
               ["CO","Colorado"],
               ["FL","Florida"],
               ["GA","Georgia"],
               ["NY","New York"],
               ["SD","South Dakota"]
            ]
   })
});
Now that we have created our combo box we need to add an event listener. What we are saying is when a user selects something do the following. Using the grid reference we created at the top of the function we can grab the grids store (datasource) and use a built in method filter. The filter method takes two arguments, the column you want to filter on and the value you want to to filter.
cb.addListener("select",function(combo,record,index){
var state = record.data.value;
//filter the records grid.getDataSource().filter("STATE",state);
});
The filter is now setup, now we just need to add it to our toolbar. The first line ads a spacer in so that our toolbar items are right aligned. Next I add a button that can be used to remove the filter. After a state is selected this will give us a way to return back to the grids original state. We will look at the event handler for this button in a second. Then next we create a separator between our button and combo box and finally add our combo box.
Ext.fly(tbar.addSpacer().getEl().parentNode).setStyle('width', '100%');
tbar.addButton({
   text:"Remove Filter",
       icon:"plugin.png",
       cls:"x-btn-text-icon",
       tooltip:"Remove Filter",
       handler:removeFilter
      });
tbar.add(new Ext.Toolbar.Separator());
tbar.add(cb);
Finally here is how the grids original state is restored. The store has a method for removing the filter and I simply reset the combo box the empty text is restored.
function removeFilter(){
      store = grid.getDataSource()
      //remove the data filter       store.clearFilter();
      //clear the value of the combo box       cb.clearValue();
      //reset it so empty text shows up       cb.reset();
   }

Hopefully this tutorial will show you that there is a great deal of customizing that can go into the grids. Hopefully this will inspire you to create your own filters. If you have any comments or questions just let me know. Plus I am looking for more ideas on extending the grid. If you have something you are trying to accomplish but not sure how just let me know. Here is the full code for the tutorial.

<html>
<head>
<title>Grid Filter Exmaple</title>

<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/toolbar/toolbar.js"></script>   
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/button/button.js"></script>

<script type="text/javascript">
function init(){
      grid = ColdFusion.Grid.getGridObject("ArtistGrid");
      var gridHead = grid.getView().getHeaderPanel(true);
      var tbar = new Ext.Toolbar(gridHead);
      
cb = new Ext.form.ComboBox({
   id:"stateFilter",
   emptyText:"Filter By State",
   mode:"local",
   triggerAction:"all",
   displayField:"text",
   valueField:"value",
         store:new Ext.data.SimpleStore({
            fields: ["value", "text"],
            data: [
               ["CA","California"],
               ["CO","Colorado"],
               ["FL","Florida"],
               ["GA","Georgia"],
               ["NY","New York"],
               ["SD","South Dakota"]
            ]
   })
});

      cb.addListener("select",function(combo,record,index){
         var state = record.data.value;
         //filter the records          grid.getDataSource().filter("STATE",state);
      });

Ext.fly(tbar.addSpacer().getEl().parentNode).setStyle('width', '100%');
tbar.addButton({
   text:"Remove Filter",
       icon:"plugin.png",
       cls:"x-btn-text-icon",
       tooltip:"Remove Filter",
       handler:removeFilter
      });
      tbar.add(new Ext.Toolbar.Separator());
      tbar.add(cb);
      console.log(Ext);
}
   function removeFilter(){
      store = grid.getDataSource()
      //remove the data filter       store.clearFilter();
      //clear the value of the combo box       cb.clearValue();
      //reset it so empty text shows up       cb.reset();
   }
</script>
</head>
<body>
   
   <link href="/CFIDE/scripts/ajax/ext/resources/css/ytheme-aero.css" rel="stylesheet" type="text/css">
   

   <cfquery name="getArtists" datasource="cfartgallery">
   SELECT artistId, firstname, lastname, address, city, state, postalcode, email
   FROM Artists
   </cfquery>
   
   <cfset args = structNew()>
   <cfset args.name = "ArtistGrid">
   <cfset args.format = "html">
   <cfset args.query = "getArtists">
   <cfset args.stripeRows = true>
   <cfset args.selectColor = "##D9E8FB">
   <cfset args.width = 600>
   
   <cfform>
      <cfgrid attributeCollection="#args#">
         <cfgridcolumn name="artistid" display="false">
         <cfgridcolumn name="firstname" header="First Name">
         <cfgridcolumn name="lastname" header="Last Name">
         <cfgridcolumn name="email" header="Email Address">
         <cfgridcolumn name="address" header="Address">
         <cfgridcolumn name="city" header="City">
         <cfgridcolumn name="state" header="State">
         <cfgridcolumn name="postalcode" header="Zip">
      </cfgrid>
   </cfform>
   
   <cfset ajaxOnLoad("init")>

</body>
</html>

Comments

#1 Posted By: Samer Salameh Posted On: 3/11/08 6:53 AM
Thank you very much.
Can you update the example to make Combo box loaded using json?
#2 Posted By: Frank Wheatley Posted On: 3/11/08 9:23 AM
I was able to populate the combo box with a query
   cbCategory = new Ext.form.ComboBox({
    id:"categoryFilter",
    emptyText:"Fund Category",
    mode:"local",
    triggerAction:"all",
    displayField:"text",
    valueField:"value",
   
    store:new Ext.data.SimpleStore({
       fields: ["value", "text"],
       data: [
       <cfoutput query="qFndCat">
         ["#fndcatid#","#fndcatdes#"]<cfif qFndCat.currentrow LT qFndCat.recordcount>,</cfif>
      </cfoutput>
      ]
    })
   });

Now I need to figure out how to filter on multiple fields
#3 Posted By: Dan Vega Posted On: 3/11/08 9:28 AM |
Author Comment
@Frank - Do you mean for that one combo box to filter on multiple columns or the ability to have multiple filters.
#4 Posted By: Frank Wheatley Posted On: 3/11/08 1:18 PM
I have a cfgrid for mutual fund performance values. I have multiple combo boxes for 'Fund Family', 'Fund Category',...........

The filtering needs to be on multiple columns. I may want to select only Vangard, Large Cap funds.

I was able to do this by adding a bind to a cfc on the cfgrid. However, I'd like to do it without a trip to the db after each selection. The query is somewhat complex.
#5 Posted By: Dan Vega Posted On: 3/11/08 1:21 PM |
Author Comment
How are you getting the data for the grid. Is it a one trip query or are you binding to a cfc using paging?
#6 Posted By: Frank Wheatley Posted On: 3/11/08 1:32 PM
One procedure call. I populate the combo boxes with a QofQ from the cfprocresult. Works great for single filter.

I used the bind cfc and paging, but it called the cfc every time the filter or sort changed. This method seem much more efficient if possible.

BTW - thanks for the example and replies.
#7 Posted By: Dan Vega Posted On: 3/11/08 1:36 PM |
Author Comment
If you are paging you are going to have to poll the server each time. The reason for this is when you use paging your actually grabbing only the data need. So if your page size is 10 its only grabbing 10 records so that is the only data you can filter on.
#8 Posted By: Brian Posted On: 5/12/08 10:12 AM
I have my first Cf8 html/AJAX data grid working, but my Javascript experience is limited. How would I create a simple Master detail setup for a search page. I have the whole thing enclosed in a cfform tag. I have a simple search form with a submit button and detail fields under the master grid. When I click submit, I want the cfgrid to refresh (that will pass my search parameters, currently only working on page load). Then when I select a grid row, I want the a new cfc to run to get the detail data for that row that will show in the fields below it. I have modified the original CFC to give me detail when a single key is passed. Haven't found a good non-flash, non-flex example. Have you seen any such examples or know how to do that? Thanks.
#9 Posted By: Dan Vega Posted On: 5/12/08 10:37 AM |
Author Comment
Brian - So you are looking for an example that shows a data grid and when you click on a row the details for that record would show below the grid? If thats correct I will whip up an example for you.
#10 Posted By: Brian Posted On: 5/12/08 10:44 AM
Dan, Yes that would be much appreciated.
#11 Posted By: Brian Posted On: 5/21/08 2:40 PM
Dan,
I've continued to try to work this master-detail app, but I'm hung up on 2 fronts.
1) Passing the clicked on key from the datagrid master to a CFC for populating the detail fields. However, I can get the data from the grid, including the key to show up in the detail area and I can invoke the CFC with a set key value.
2) My javascript form submittals are failing, where I try to submit new search data posting the form to the current page. However I can bind the grid to some of the search fields and click the refresh in the grid and it updates the grid with the new parameters. Perhaps your example will clarify what I'm doing wrong here.
#12 Posted By: Dan Vega Posted On: 6/5/08 10:47 AM |
Author Comment
@Brian - Can you email a full code example so I can see whats failing? I am sorry for the delay In getting back to you, I have been swamped.
#13 Posted By: Brian Posted On: 6/5/08 2:11 PM
I got those 2 problems resolved. One of my keys was to use cfajaxproxy to submit my creates/updates and deletes.

I am having trouble finding something so I can provide a message to the user regarding the status of a request. The little icon on the grid is not adequate. Ideally something like a slider displaying % complete or at least "please wait". I saw grid has a loadmask.msg attribute, but have not got it to work.

Also do you have a good example or reference for doing the search within search results for cfgrid, but using the form outside the grid?
#14 Posted By: knk Posted On: 10/16/08 10:51 AM
Great Example! I'm trying to mimic this same example with my data but something is wrong with the combo box. The inline are there but it does nothing. please help me!
<cfquery name="ListAllContent" datasource="#Request.Config.DSN.Primary#" >
         SELECT
            m.Id AS id,
            m.LastName + ', ' + m.FirstName AS FullName,
            m.CompanyId,
            m.EmailAddress,
            m.WorkPhone,
            c.Name AS CompanyName,
p.Name AS PositionName,
            acstat.Name AS AccountStatus
         FROM
            nma_Members AS m INNER JOIN
            nma_Companies AS c ON m.CompanyId = c.Id INNER JOIN
            nma_AccountStatuses AS acstat ON m.AccountStatusId = acstat.Id INNER JOIN
            nma_Positions AS p ON m.PositionId = p.Id
         <!--- WHERE
            (acstat.Id <> '4')
            AND
            (acstat.Id <> '3') --->
      </cfquery>

<cfset args = structNew()>
<cfset args.name = "MemberGrid">
<cfset args.format = "html">
<cfset args.align="middle">
<cfset args.query = "ListAllContent">
<cfset args.stripeRows = true>
<cfset args.selectColor = "##D9E8FB">
<cfset args.width = 600>
<cfset args.sort = true>
   <cfset args.pagesize="25">
   
<cfform>
<cfgrid attributeCollection="#args#">
<cfgridcolumn name="id" display="no"/>
       <cfgridcolumn name="PositionName" header="Role" width="50">
<cfgridcolumn name="FullName" header="Full Name" width="150">
<cfgridcolumn name="CompanyName" header="Company" width="170">
<cfgridcolumn name="EmailAddress" header="Email Address" width="180">
<cfgridcolumn name="AccountStatus" header="Account Status" width="50">
</cfgrid>
</cfform>

cb = new Ext.form.ComboBox({
id:"AccountStatus",
emptyText:"Filter By Account Status",
mode:"local",
triggerAction:"all",
displayField:"AccountStatus",
valueField:"AccountStatusId",
store:new Ext.data.SimpleStore({
fields: ["AccountStatus", "AccountStatus"],
data: [
["1","Active"],
["2","Inactive"],

]
})
});

cb.addListener("select",function(combo,record,index){
var AccountStatusID = record.data.value;
grid.getDataSource().filter("STATE",AccountStatusId); //filter the records
});
#15 Posted By: knk Posted On: 10/16/08 10:55 AM
BTW I think this is what my problem is with this line:grid.getDataSource().filter("AccountStatus",Account); //filter the records

I'm not sure what to args go there
#16 Posted By: Dan Vega Posted On: 10/16/08 11:06 AM |
Author Comment
This is probably the issue you are having. The state column was for my example you will have to change that to AccountStatus.

grid.getDataSource().filter("STATE",AccountStatusId);

Let me know if that works for you.
#17 Posted By: knk Posted On: 10/16/08 2:07 PM
I figured that part out after I made the posting. Sorry! However when I select a filter it makes the data disappear. When I hit the remove filter button the data returns! It seems like it's not finding a match. No errors in firebug. Here's my updates code

function init(){

    grid = ColdFusion.Grid.getGridObject("MemberGrid");
    //var gridFoot = grid.getView().getFooterPanel(true); //make the footer
var gridHead = grid.getView().getHeaderPanel(true); //make the header so I can add button and CB

   var tbar = new Ext.Toolbar(gridHead);
      

cb = new Ext.form.ComboBox({
id:"AccountFilter",
emptyText:"Filter By Account Status",
mode:"local",
triggerAction:"all",
displayField:"text",
valueField:"value",
store:new Ext.data.SimpleStore({
fields: ["value", "text"],
data: [
["1","Active"],
["2","Inactive"]

]
})
});

cb.addListener("select",function(combo,record,index){
var AccountStatus = record.data.value;
var AccountStatus2 = record.data.text;
alert(AccountStatus2);

grid.getDataSource().filter("AccountStatus",AccountStatus2); //fi
//alert("ok");
});
Ext.fly(tbar.addSpacer().getEl().parentNode).setStyle('width', '100%');
tbar.addButton({
text:"Remove Filter",
icon:"plugin.png",
cls:"x-btn-text-icon",
tooltip:"Remove Filter",
handler:removeFilter
});
tbar.add(new Ext.Toolbar.Separator());
tbar.add(cb);
console.log(Ext);
}
function removeFilter(){
store = grid.getDataSource()
store.clearFilter();
cb.clearValue(); //clear the value of the combo box
cb.reset(); //reset it so empty text shows up
}


<link href="/CFIDE/scripts/ajax/ext/resources/css/ytheme-aero.css" rel="stylesheet" type="text/css">
<cfquery name="ListAllContent" datasource="#Request.Config.DSN.Primary#" >
         SELECT
            m.Id AS id,
            m.LastName + ', ' + m.FirstName AS FullName,
            m.CompanyId,
            m.EmailAddress,
            m.WorkPhone,
            c.Name AS CompanyName,
p.Name AS PositionName,
            acstat.Name AS AccountStatus,
            acstat.id as StatusID
         FROM
            nma_Members AS m INNER JOIN
            nma_Companies AS c ON m.CompanyId = c.Id INNER JOIN
            nma_AccountStatuses AS acstat ON m.AccountStatusId = acstat.Id INNER JOIN
            nma_Positions AS p ON m.PositionId = p.Id
         <!--- WHERE
            (acstat.Id <> '4')
            AND
            (acstat.Id <> '3') --->
      </cfquery>

<cfset args = structNew()>
<cfset args.name = "MemberGrid">
<cfset args.format = "html">
<!--- <cfset args.align="middle"> --->
<cfset args.query = "ListAllContent">
<cfset args.stripeRows = true>
<cfset args.selectColor = "##D9E8FB">
<cfset args.width = 800>
<!--- <cfset args.sort = true>
   <cfset args.pagesize="25"> --->
   
<cfform>
<cfgrid attributeCollection="#args#">
<cfgridcolumn name="id" display="false"/>
       <cfgridcolumn name="StatusID" display="false"/>
       <cfgridcolumn name="PositionName" header="Role" >
<cfgridcolumn name="FullName" header="Full Name" >
<cfgridcolumn name="CompanyName" header="Company" >
<cfgridcolumn name="EmailAddress" header="Email Address" >
<cfgridcolumn name="AccountStatus" header="Status" >
</cfgrid>
</cfform>

<cfset ajaxOnLoad("init")>
#18 Posted By: Dan Vega Posted On: 10/16/08 2:17 PM |
Author Comment
I am almost sure your problem is with the following line. Take a look at the source but usually the column names are converted to Uppercase. So change AccountStatus > ACCOUNTSTATUS

grid.getDataSource().filter("AccountStatus",AccountStatus2);
#19 Posted By: knk Posted On: 10/16/08 2:56 PM
Thanks for the prompt response.

I made the change and still no filtered data appears

grid.getDataSource().filter("ACCOUNTSTATUS",AccountStatus2);
#20 Posted By: knk Posted On: 10/16/08 3:13 PM
in your example you have:

var state= record.data.value;

Is this the actual data from the column on the grid? Or from the simple store?
#21 Posted By: Dan Vega Posted On: 10/16/08 3:19 PM |
Author Comment
record gets passed in from our select method. If you use Firebug you should be able to log record and see what data is coming over.
#22 Posted By: knk Posted On: 10/16/08 3:42 PM
Ok, I took your exact code and save it on the server. It appears just like your screen shot. When I tried to filer it did nothing. Also, the puzzle piece image icon does not show up on the button. Does this mean anything to you?
#23 Posted By: knk Posted On: 10/16/08 3:56 PM
OK I got your code to work! Still the icon isn't showing up on the button. I'm still trying to get mine working.....
#24 Posted By: knk Posted On: 10/16/08 4:02 PM
IT WORKS!!!!!!!!!! WOOHOOO!! YES! Dan you r the man! Now I have an extra blank column that needs to be erased I don't know where it's coming from???

THANKS!
#25 Posted By: knk Posted On: 10/17/08 12:30 PM
Ok I need help. I modified the code so I can use paging. I couldn't figure out how to pass paging in the struct so I created a cfc. So I have 3 files now that consist of the JS, form and the component. The grid is working and filtering but it's only filtering the data on that page. It's not filtering all the data. How can I fix this? Here's my code:

JS:

function init(){

    grid = ColdFusion.Grid.getGridObject("MemberGrid");
    //var gridFoot = grid.getView().getFooterPanel(true); //make the footer
var gridHead = grid.getView().getHeaderPanel(true); //make the header so I can add button and CB

   var tbar = new Ext.Toolbar(gridHead);
      

cb = new Ext.form.ComboBox({
id:"AccountFilter",
emptyText:"Filter By Account Status",
mode:"local",
triggerAction:"all",
displayField:"text",
valueField:"value",
store:new Ext.data.SimpleStore({
fields: ["value", "text"],
data: [
["Active","Active"],
["Inactive","Inactive"],
          ["Historical","Historical"],
          ["Guest","Guest"],
         

]
})
});

cb.addListener("select",function(combo,record,index){
var AccountStatus = record.data.value;
var AccountStatus2 = record.data.text;


grid.getDataSource().filter("ACCOUNTSTATUS",AccountStatus); //fi

});
Ext.fly(tbar.addSpacer().getEl().parentNode).setStyle('width', '100%');
tbar.addButton({
text:"Remove Filter",
icon:"plugin.png",
cls:"x-btn-text-icon",
tooltip:"Remove Filter",
handler:removeFilter
});
tbar.add(new Ext.Toolbar.Separator());
tbar.add(cb);
console.log(Ext);
}
function removeFilter(){
store = grid.getDataSource()
store.clearFilter();
cb.clearValue(); //clear the value of the combo box
cb.reset(); //reset it so empty text shows up
}

CFFORM:

<cfform>
<cfgrid format="html" striperows="yes" selectcolor="##D9E8FB" sort="true" width="500" name="MemberGrid" pagesize="500" bind="cfc:#Request.Config.CustomComponentDir#.Members.getMembers({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
<cfgridcolumn name="ID" display="false"/>
       <cfgridcolumn name="STATUSID" display="false"/>
       <cfgridcolumn name="POSITIONAME" header="Role" >
<cfgridcolumn name="FULLNAME" header="Full Name" >
<cfgridcolumn name="COMPANYNAME" header="Company" >
<cfgridcolumn name="EMAILADDRESS" header="Email Address" >
<cfgridcolumn name="ACCOUNTSTATUS" header="Status" >
</cfgrid>
</cfform>

<cfset ajaxOnLoad("init")>

CFC:
<cfcomponent>
   <cffunction name="getMembers" access="remote">
      <cfargument name="page" required="yes">
       <cfargument name="pageSize" required="yes">
       <cfargument name="gridsortcolumn" required="yes">
       <cfargument name="gridsortdirection" required="yes">
       <cfquery name="ListAllContent" datasource="#Request.Config.DSN.Primary#" >
         SELECT
            m.Id AS id,
            m.LastName + ', ' + m.FirstName AS FullName,
            m.CompanyId,
            m.EmailAddress,
            m.WorkPhone,
            c.Name AS CompanyName,
p.Name AS PositionName,
            acstat.Name AS AccountStatus,
            acstat.id as StatusID,
            getdate() as currenttime
            
         FROM
            nma_Members AS m INNER JOIN
            nma_Companies AS c ON m.CompanyId = c.Id INNER JOIN
            nma_AccountStatuses AS acstat ON m.AccountStatusId = acstat.Id INNER JOIN
            nma_Positions AS p ON m.PositionId = p.Id
            <cfif gridsortcolumn neq ''>
             order by #gridsortcolumn# #gridsortdirection#
            </cfif>
         
      </cfquery>
      <cfreturn queryconvertforgrid(ListAllContent,page,pagesize)/>
   </cffunction>
</cfcomponent>
#26 Posted By: Dan Vega Posted On: 10/17/08 1:04 PM |
Author Comment
You are not going to be able to page and filter. Paging loads only the data it needs so your filter will only be on the data that is currently loaded. You may want to implement more of a search feature than a filter feature.
#27 Posted By: Frank Wheatley Posted On: 10/17/08 1:10 PM
add an argument to your bind and filter it in the CFC.
this may not be the exact code

bind="cfc:#Request.Config.CustomComponentDir#.Members.getMembers({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{AccountFilter})">
#28 Posted By: knk Posted On: 10/21/08 12:16 PM
Hi,

Another question. I want to add another column to grid that has a hyperlink called Edit. Each row will have a Edit link. I can't seem to make the href attributes work correctly. I added the column on but it just displays a small line in the column I added? Any Suggestions?

Thanks
#29 Posted By: Jim Papaleo Posted On: 11/4/08 2:34 PM
For knk post #28:
you need to create a function:

var myf1 = function(data,cellmd,record,row,col,store) {
if(data > "") return "<a href=sodetail.cfm?key=" + data + ">" + data + "</a>";
else return data;
}

Call the function when the grid is loaded

// the init()
function init(){
grid = ColdFusion.Grid.getGridObject("ShipGrid");
cm = grid.getColumnModel();
cm.setRenderer(1,myf1);
grid.reconfigure(grid.getDataSource(),cm);
#30 Posted By: Bud Hines Posted On: 12/13/08 3:21 PM
Thanks for the example. You show in another example how to provide an add and delete button. This works fine in a cfm file with nothing in it. When I insert the grid logic betweeen my headers, side menu and footers the button on the grid disappear? Do you have any idea why this is happening?

On a separate note, I needed to comment out this call in my application cfc to get the data to show up: <cffunction name="onRequest">

Any help would be appreciated.

thanks,
Bud
#31 Posted By: Bonnie Posted On: 12/16/08 1:55 PM
I get an error on using console.log(Ext); in my code. I copied your code to run it and see if it's my code or that command that is causing problems. I get the same error on this code. Maybe it's a known browser issue? I'm using IE6.

I am also unalbe to see any tooltips from these 'addButton()' functions. Is this too a known IE6 problem? I am able to get the whole thing to seemingly work fine without using the console function, but I really need those tooltips.

Any advice is appreciated.
#32 Posted By: Michael Posted On: 12/18/08 1:16 AM
I have been using your code for some time now with great results!! One question though...I have tried time and time again to add MULTIPLE filters but am unsuccessfull...Is there a way to have the ability to filter based off of two different criteria (either both at the same time or individually?)

Example, I want to filter the grid based upon date and time. Currently i can filter by date, but what if i want to filter by time instead? What if i wanted to filter by date and THEN time...

Is this posisble?
#33 Posted By: icd Posted On: 2/25/09 11:05 AM
I created a query to pull the list of states to display in the filter box...But I don't see the list. It filters...The items are there but I can't seem to display them...Any suggestions...
Code:
<script type="text/javascript">
<cfquery name="qListArtists" datasource="cfartgallery">
SELECT DISTINCT state
FROM Artists
ORDER BY state
</cfquery>

function init(){
grid = ColdFusion.Grid.getGridObject("ArtistGrid");
var gridHead = grid.getView().getHeaderPanel(true);
var tbar = new Ext.Toolbar(gridHead);

cb = new Ext.form.ComboBox({
id:"stateFilter",
emptyText:"Filter By State",
mode:"local",
triggerAction:"all",
displayField:"text",
valueField:"value",
store:new Ext.data.SimpleStore({
fields: ["value", "text"],
data: [
<cfoutput query="qListArtists">
          ["#state#"]<cfif qListArtists.currentrow LT qListArtists.recordcount>,</cfif>
</cfoutput>
]

})
});

cb.addListener("select",function(combo,record,index){
var state = record.data.value;
grid.getDataSource().filter("STATE",state);
});
#34 Posted By: Bonnie Posted On: 2/25/09 2:00 PM
ICD, are you by chance using that last upgrade of Firefox 2? For some reason, I am using a bind attribute on a cfselect for my states dropdown and now I can see the states in the dropdown in IE but they don't show in Firefox. Anyone else having problems with these binds in Firefox?
#35 Posted By: Catbollu Posted On: 7/26/10 12:15 PM
A few comments back Posted By: Dan Vega Posted On: 5/12/08 10:37 AM |
You were working on an example to show how to click a row and show details. Is there anywhere I might see this example?
#36 Posted By: Dan Vega Posted On: 7/29/10 3:17 PM |
Author Comment
I will put together an example for you shortly...
#37 Posted By: Catbollu Posted On: 7/29/10 3:38 PM
I am also trying to get a cfgridupdate to work and having issues. BUt I am not sure where to post that
#38 Posted By: Dan Vega Posted On: 8/2/10 11:05 PM |
Author Comment
Here is an example of showing the details of a selected row.

http://www.danvega.org/blog/index.cfm/2010/8/2/Sho...


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.