While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aesthetic purposes. In addition I also wanted to include a result count so that the user would know which set of the results they were looking at out of the total.
It took a bit of searching but I ended up combining a few code snippets and thought I would share the results of my endeavor. I hope you find them helpful!
Step by step solution:
( skip to the bottom if you want the full source – requires minimal modification )
Step 1:
- Would be to create your <cfgrid> and a .cfc to populate it with some data.
Here is a great <cfgrid> tutorial if you require assistance on creating a <cfgrid> as I will not be covering that here:
http://www.forta.com/blog/
Step 2:
- It is important that the following <script> be placed inside of the <head> </head> tags of your page:
("YourGridName" should be replaced with the name of your cfgrid )
NOTE: You should replace the "showWin" function which with whatever function you want to run as the handler for each button.
If you only want to add buttons (no result set count) change the following to false: displayInfo: true,
If you only want the result set count remove the following:
Step 3:
- Calling your init script - place the following code after your <cfgrid> inside the <body> tag:
CONCLUSION:
Using the script provided you should be able to add as many buttons as space provides to the bottom of your cfgrid, and have the current result set count at the bottom right side of your bar.
I have attached a demo page below but you will need to replace the <cfgrid> with your own, and "YourGridName" in the init function to make it work
References Used ( The above code is a combination of the following ):