jQuery Replacements for CFGRID, CFWINDOW, and CFTOOLTIP

Ajax , ColdFusion , Default , Web Development Add comments

I recently completed the beta version of CFjqAjax.  This is a library of custom tags that replicate the CFGRID, CFWINDOW, and CFTOOLTIP tags from ColdFusion 8.  The CF8 tags work, but I find YUI and Ext much harder to work with than jQuery, and the file size of the JavaScript libraries that CF8 includes is excessive.  So, I created CFjqAjax.

See the demo

View the ReadMe (documentation) file

Download CFjqAjax

Current Version: 0.7  (beta)

UPDATE (9/2/08):  This project is now on RIAForge.  http://CFjqAJAX.riaforge.org

UPDATE (11/10/08):  If you have questions or suggestions, please use the RIAforge site - not this blog! If you have comments feel free to share below, but I do not regularly monitor this blog to answer questions.

 

NOTES:
The functionality of these tags is based on three existing jQuery libraries.
1. Flexigrd (http://webplicity.net/flexigrid)
2. jqModal (http://dev.iceburg.net/jquery/jqModal/)
3. jTip "Even More Updated" (http://users.evtek.fi/~mikkowu/jtip/index.html)

 

61 responses to “jQuery Replacements for CFGRID, CFWINDOW, and CFTOOLTIP”

  1. Gary Fenton Says:
    I love jquery too so it's great to see someone has created CF tags that use it.

    However... while it looks good in FF3 the grid does not render correctly in IE7. The firstname and lastname column headers have been put into their own column so there are actually 4 columns showing, not 2.

    CF_window does not render correctly in IE7. The grip bar in the bottom right is misaligned and the window doesn't reduce its X size when made smaller.

    In both IE7 and FF3 the loading anim from cf_tooltip sometimes remains on the screen if you move quickly between the two example tooltips.

    I hope you don't mind me reporting these bugs?
  2. Michael Sprague Says:
    Thanks Gary. It looks like the server version of the examples is rendering a little different than my local copy. I will get this corrected today.

    Yes, please report any bugs here.
  3. Michael Sprague Says:
    The rendering issues have been resolved. I simply forgot the doctype in the header of the HTML on the example page.
  4. Henry Ho Says:
    the demo page is not rendering in IE7.. Script error.

    Good luck on your project!
  5. Henry Ho Says:
    yup, they work now.

    suggestion: upload to http://www.riaforge.org/
  6. Michael Sprague Says:
    Thanks Henry. Yes, RIAforge is my eventual plan. Right now I'd like to work out the minor bugs with a smaller group, though. Probably in a couple weeks.
  7. Gary Fenton Says:
    The quick search in your demo is case sensitive. e.g. richard does not find Richard.

    Looking good in IE7. :-) Paulo has more cool features planned for Flexgrid like inline editing of records, but you probably read that in his forum.
  8. Andy Lynch Says:
    This looks very nice...

    Another glitch that I can see in IE6: If you open up the quick search panel on the grid, then click show window underneath, then the field selection drop-down shows through on top of the window that appears.

    Keep up the good work.
  9. Joe Danziger Says:
    Great job at getting these out there! This looks like a great alternative to the built in tools. Go jQuery!
  10. Andy Wu Says:
    Nice job Mike!

    I had to make a couple of minor changes. I added #cgi.context_path# to the defaults of the pathToXxx attributes which makes it work in the context of a webapp.

    Also jquery126-min.js and jtip.inline-support.js had to be renamed to jQuery126-min.js and jTip.inline-support.js.

    Thanks
  11. Vince Bonfanti Says:
    Nice work!

    The demo you're showing here seems to be slightly different than what's in the download package--look at the contents of the CF_WINDOW demo.
  12. Scott Stroz Says:
    Fantatstic. This is great stuff.
  13. Henry Says:
    any plan for supporting CFDIV?

    any plan to submit these to Railo / OpenBD?
  14. Zac Spitzer Says:
    Look great...

    It would great to be able to make the existing cf layout tags pluggable library wise, similiar to using a custom xml file with cfchart
  15. KC Says:
    Very nice, although the tooltip has a small problem in Opera 9.5. The tooltip only stays open if you don't move your mouse. Once you move your mouse, it closes and re-opens.
  16. charlie griefer Says:
    hey michael:

    this is awesome. thanks for putting it together and sharing it.

    found a tiny bug (maybe not a bug, but a point of clarification)... in tooltip.cfm, you've got a <cfparam> for attributes.pathTojTipCSS with a default path specified. however, in the demo code, your custom tag call has an attribute for pathTojqTipCSS.

    took me a few minutes to figure out why the path i specified in the custom tag wasn't being picked up :)

    thanks again!
  17. William from Lagos Says:
    This is great stuff. I love this.
  18. Marco Antonio Says:
    Great job. Flexigrid search stills searching for case sensitive.
    Cheers
    Marco Antonio
  19. Eric Says:
    Wow. Get on Riaforge maybe or somewhere we can track the project...I want to use some of this goodness.
  20. Michael Sprague Says:
    Thanks to everyone for the overwhelming positive response to this project. It was great to come back from a long weekend and see all this. Because of the interest I have seen, I have posted this project on RIAForge - http://CFjqAjax.riaforge.org

    Please report any bugs/issues to the RIAForge site. There is also a forum there.

    Some more specific responses...

    @Gary - The search in the demo is case sensitive because I am bluffing a data source using Query of Queries. I can correct that in the demo, but it should not impact use with a real data source.

    @Andy L - I have logged the IE6 bug (select boxes show through) and will try to correct that for the next release.

    @Andy W - Thanks for letting me know about this. I hadn't considered how other Web servers would handle the files. I only tested with IIS. I will correct this in the next release.

    @Henry - I think CFDIV would be fairly easy to replicate without needing any additional jQuery extensions, so I will give it a shot. Also, I am interested in submitting these to Railo and OpenBD. I will probably hold off on that, though, until a full 1.0 release.

    @KC - I haven't tested any of this in Opera. I will try to get Opera support into the next release, assuming the Flexigrid, jTip, and jqModal will support it.

    @Charlie - I will correct the bad reference to pathtojTipCSS in the next release.
  21. John Farrar Says:
    Curious... I don't see docs anywhere that this grid allows edits. Does it? (Inline edits, or just edits of the data set, or when a row is selected allow the browser to know what row that is and pull the data to a form and then push it back, and what about pushing the update(s) back to the server?) We were using jqGrid before this... and are seeing if it does a full feature compare or not.
  22. Michael Sprague Says:
    John- No, this solution does not do in-place editing yet. From what I understand, the developers of Flexigrid are working on it, though. When they add it, I will most likely add it to this project.
  23. Michael Sprague Says:
    After reading John's post, I took a good look at jqGrid. Anyone have any thoughts on replacing Flexigrid with jqGrid in this project? It seems to have more functionality. Anyone know of any down sides?
  24. Brian Says:
    Trying to get the id of a row or rows selected when clicking a button.

       deleteperson = function () {
          confirm('Delete ' + $('.trSelected').length + ' items?')

       }   

    I get the total count but can't seem to get the values.
  25. Brian Says:
    I figured it out ...

       deleteperson = function () {
          
          
          if($('.trSelected').length>0){
             if(confirm('Delete ' + $('.trSelected').length + ' items?')){
       var items = $('.trSelected');
          var itemlist ='';
          for(i=0;i<items.length;i++){
                   itemlist+= items[i].id.substr(3)+",";
                }
                alert(itemlist);
             }
          } else
                alert('Please make a selection')
          }
  26. Gary Gilbert Says:
    Hi Michael,

    Great work on the tags! Any plans on wrapping more of the jquery ui into tags?

    Gary
  27. Michael Sprague Says:
    Gary - If you want to make some suggestions, I am certainly open to building more into it. You can use the RIAForge page to make enhancement requests.
  28. salvatore fusto Says:
    Hi Michael,
    i've used jqGrid: it has a very good api, expecially in editing grid rows; as far as i know its lacks, with respect to flexgrid, are:
    1) you cannot rearrange columns dragging them;
    2) you have to display links, one for each column, to display/hide columns: flexgrid way of doing this is more immediate and less intrusive.
    regards
    salvatore
  29. John Farrar Says:
    Salvatore,
    You are right on all those points... but grids are used for forms often. If we deliver to our customers on grid for data entry and another for display it presents to our customers that we are not 'masters'. They by nature expect everything! lol We need this grid or something like it with ease of coding and data entry in one package.
  30. salvatore fusto Says:
    John, the best is that jqgrid, you are using in your coop project, would drag columns, exactly as flexgrid: this is an important feature for a user being able to display data, ie columns, in the order he wants.
    jqgrid is ideal for forms input: do you know that in the new release you have an api function to copy all cells of the selected row in the corrisponding fields of a form with a single click?
    regards
  31. salvatore fusto Says:
    John, the best is that jqgrid, you are using in your coop project, would drag columns, exactly as flexgrid: this is an important feature for a user being able to display data, ie columns, in the order he wants.
    jqgrid is ideal for forms input: do you know that in the new release you have an api function to copy all cells of the selected row in the corrisponding fields of a form with a single click?
    regards
  32. Toddzilla Says:
    Thanks for this great-looking alternative to the very disappointing <cfgrid>. Your README mentions binding the grind to CFC (I imagine like <cfgrid>), but I don't see how that works. The notes say you need version 1, but the release is only 0.7. Is binding to a CFC coming? Is there a way to get version 1?
  33. Michael Sprague Says:
    Toddzilla - You should be able to bind to a CFC by passing the path into the bind attribute like this...

    bind="cfc:test.cfc?method=getgrid&x=1"

    You'll just need to make sure your CFC method has access="remote" on it.

    If I misunderstood the request, please let me know by submitting the full issue at the riaforge site... http://cfjqajax.riaforge.org
  34. Jim Says:
    Mike,

    Your CF_grid is great. I love the look and function. But, I do have a problem as it won't
    load my data into the grid. I'm going to post the code to our CFUGCNY to see if anyone can spot my problem.

    Jim
  35. Michael Sprague Says:
    Jim - I responded on the CFUG list, but for the benefit of those reading here...

    In order to use the tag to return data, you need t output the data from your ajax call using the included cf_gridconvert tag. It will not work with the queryconvertforgrid tag that is included in ColdFusion 8. That function is only applied to the built-in CFGRID, and will not work for Flexigrid.
  36. Jim Says:
    Mike,

    I got it the data to display, but the column sort, Num Rows and search functions don't work. I bind this way, not throught a somepage.cfm, as in your example.

    bind="cfc:portal.cfc?method=GetShipments&thisDSN=#myDSN#&thisAcct=#myAcct#&numrows=#myNumRows#&sortcolumn=#form.sortcolumn#&sortdir=#mySrt#"

    Also I need to date and dollar format and link from the grid data. Would that follow jquery syntax?
  37. Michael Sprague Says:
    Jim - I would recommend that you start from the example I provided rather than trying to use it a different way. Have your CFM file use the CFC rather than trying to call the CFC directly with access="remote". I think arguments are getting lost when flexigrid tries to pass information back to the CFC, but I can't tell without seeing all the code.
  38. Spiraldev Says:
    I am using the cf grid and I get a javascript error when I search for Gary saying ID is undefined. I only get this error in IE 7 works fine in FF
  39. Jean Roy Says:
    This is the first time I am using cfgrid for displaying and updating data. I am having problem with :
    1) Formatting date in cfgrid. Currently, it gives me "March 15, 2005 00:00:00". I only want the date to be "March 15, 2005".

    2) The metastatic_loc supposes to display a list of location from a lookup table. Currently, it displays the id from that lookup table. How do I fix this problem so that it will have a field list(brain, lung, CNS, liver,...) to allow user to select one from the list ?

    3) How do I code to display the result grid after data is updated ?

    4) How do I code to insert new row to the existing cfgrid ?
    Thank you for helping me.

    <cfif (isDefined("MRN") AND len(trim(MRN)) neq 0)>
       <cfinvoke component="CFCs/ICT_DataStore" method="ListMetLoc" returnvariable="qGetMetLoc">
       <cfset Metastatic_loc = qGetMetLoc.Metastatic_loc>
    </cfif>
    <cfform name="metForm" id="metForm">
    <!---<cfdump var=#CreateObject("component", "CFCs.ICT_DataStore").dispMetast(MRN)# />
    --->
       <cfgrid name="MetGrid" format="html" selectmode="edit" delete = "Yes" sort = "Yes"
          bind="CFC:CFCs.ICT_DataStore.dispMetast((#MRN#),{cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
          onchange="CFC:CFCs.ICT_DataStore.editMetRec({cfgridaction},{cfgridrow},{cfgridchanged})"
           height="400" width="500" vspace="10" colheaderbold="yes" rowheaders="yes" colheaders="yes" selectcolor="##FF00CC" striperows="yes">
          
          <!--- CFgridcolumn tags arrange the table and control the display --->
          
          <cfgridcolumn name="MRN" header="MRN" select="no" width="100" textcolor="blue" bold="yes" headeralign="center" display="no">
          <cfgridcolumn name="Metastatic_info_id" header="Met Info Id" select="no" width="100" headeralign="center">
          <cfgridcolumn name="Metastatic_loc_id" header="Met Location Id" select="yes" width="100" headeralign="center">
          <cfgridcolumn name="Metastatic_date" header="Metastasis Date" select="yes" width="100" headeralign="center">
          
       </cfgrid>      
    <br>
       </cfform>


    <cffunction name="dispMetast" access="remote" returntype="any" hint="Display Metastasis Information">
       <cfargument name="MRN" required="yes" type="any" />
       <cfargument name="page" type="numeric" default="1">
       <cfargument name="pageSize" type="numeric" required="no" default="10">
       <cfargument name="gridsortcolumn" type="string" required="no" default="">
       <cfargument name="gridsortdir" type="string" required="no" default="">
          
          <cfquery datasource="ICT_DataStore" name="qGetMet">
             SELECT Pt_demographic.MRN, P1_speakers_tumor_type_lu.tumor_type,
                Diagnosis.date_of_dx, Metastatic_info.Metastatic_info_id,
                Metastatic_info.Metastatic_date,
                P1_speakers_metastatic_loc_lu.metastatic_loc_id

             FROM (((Pt_demographic
                      INNER JOIN Diagnosis
                         ON Pt_demographic.pt_id = Diagnosis.pt_id)
                      INNER JOIN P1_SPEAKERS_TUMOR_TYPE_LU
                         ON Diagnosis.tumor_type_id = P1_SPEAKERS_TUMOR_TYPE_LU.TUMOR_TYPE_ID)
                      INNER JOIN Metastatic_info
                         ON Diagnosis.dx_id = Metastatic_info.dx_id)
                      INNER JOIN P1_speakers_metastatic_loc_lu
                         ON Metastatic_info.Metastatic_loc_id = P1_speakers_metastatic_loc_lu.Metastatic_loc_id

             <cfif isDefined("arguments.MRN")>
                WHERE Pt_demographic.MRN = '#arguments.MRN#'
    AND Metastatic_info_id is NOT NULL
             </cfif>
          
          </cfquery>
          
    <CFRETURN QueryConvertForGrid(qGetMet,ARGUMENTS.page,ARGUMENTS.pageSize)>

    </cffunction>

    <cffunction name="EditMetRec" access="remote" output="false">
    <cfargument name="gridaction">
    <cfargument name="gridrow">
    <cfargument name="gridchanged">

       <cfif isStruct(gridrow) and isStruct(gridchanged)>
    <cfif gridaction eq "U">
    <cfset colname=structkeylist(gridchanged)>
    <cfset value=structfind(gridchanged,#colname#)>
             
             <cfquery name="UpdMetInfo" datasource="ICT_DataStore">
                UPDATE Metastatic_info SET
       <cfoutput>#colname#</cfoutput> = '<cfoutput>#value#</cfoutput>'
                WHERE metastatic_info_id = <cfoutput>#gridrow.metastatic_info_id#</cfoutput>
             </cfquery>

       <cfelse>

    <cfquery name="DeleteMet" datasource="ICT_DataStore">
              DELETE FROM metastatic_info
                WHERE metastatic_info_id = <cfoutput>#gridrow.Metastatic_info_id#</cfoutput>
    </cfquery>

    </cfif>
    </cfif>

    </cffunction>
  40. Michael Sprague Says:
    Jean,

    While I am willing to provide support for these tags when there are bugs/problems, I cannot play the role of teaching you how to program jQuery or how to extend the functionality of the grids. If you have suggestions for future functionality, I will consider those. You should submit them on the RIAforge project page at: http://cfjqajax.riaforge.org/

    Some guidance for your questions...

    1. Date formatting - This can be done through jQuery. You might want to check out the Flexigrid project for more detail.

    2. This grid will display whatever comes back in your SQL query. If you want the text to display, you will need to adjust your SQL query to pull in the text instead of the ID.

    3 and 4. See the documentation at http://www.webplicity.net/flexigrid/ There is a refresh function there, but I don't know if there is a way to insert a row without a page refresh.
  41. talarojm Says:
    I'm having the same issue Spiraldev reported except with IE6. Certain search criteria (for example 'zz' entered as the criteria for a Last Name search) gives a javascript error.

    Line:22
    Char:25
    Error:'id' is null or not an object
    Code:0
    URL:http://www.webtrenches.com/cfjq/
  42. Michael Sprague Says:
    @spiraldev and talarojm - The JavaScript error in IE should be resolved by changing line 25 of gridconvert.cfm to the following:

    {id:'#arguments.thequery.id#',cell:[<cfloop list="#displaycols#" index="curcol">'#jsStringformat(arguments.thequery[curcol][currentrow])#'<cfif curcol NEq listlast(arguments.displaycols)>,</cfif></cfloop>]}<cfif currentrow NEQ arguments.page*arguments.rowsper AND arguments.thequery.currentrow NEQ arguments.thequery.recordcount>,</cfif></cfoutput>

    It is due to an extra comma at the end of the JSON data.
  43. Rex Says:
    For the CFWindow demo... how can I get the modal window to refresh after I submit the form? If you submit your demo form, close the window, and open it again, you still see the dump. I'd like to be able to use it repeatedly without refreshing the main page. Thanks!
  44. Michael Sprague Says:
    One simple solution for this would be to have the link that opens your window run a function that re-loads the form before showing it.

    For example...

    openWindow = function() {
    $('#window_content').load('path/to/form.html');
    $('#window').jqmShow();
    };
  45. Rex Says:
    Thanks Michael. Your solution worked perfectly!
  46. Rex Says:
    I have a page with an embedded PDF using Adobe reader. I have a problem where the cfwindow displays behind the embedded PDF when it gets created. Is there a setting tweak I can make to ensure the the modal window appears on top of the PDF plugin? Thanks!
  47. Michael Sprague Says:
    @Rex - I've seen this problem before - actually happens with cfwindow and cf_window. I think it is a browser/plugin bug. The only workaround I have heard of is putting your window content in an iframe. The iframe somehow overlays the plug-in. It's not a perfect solution, but it is the only way I know of to get around it.
  48. Peter Says:
    Is there a way to change the text color for a particular column?
  49. Nikhilesh Says:
    Hi,
    I have implemented jQuery plugin, jqModal. I am facing a common issue in IE6 only. Whenever the overlay is rendered it is hiding the select [dropdowns] beneth it. I am using jQuery-1.2.6 and jqModal r13.
    It will be of great help if you can provide quick turnaround or the alternate solution.
  50. Don Says:
    I'm getting the following error, so, no data is being populated, what's wrong? thanks
    sitems.0.name is null or not an object
  51. Don Says:
    the following workaround did hot help.

    changing line 25 of gridconvert.cfm to the following:

    {id:'#arguments.thequery.id#',cell:[<cfloop list="#displaycols#" index="curcol">'#jsStringformat(arguments.thequery[curcol][currentrow])#'<cfif curcol NEq listlast(arguments.displaycols)>,</cfif></cfloop>]}<cfif currentrow NEQ arguments.page*arguments.rowsper AND arguments.thequery.currentrow NEQ arguments.thequery.recordcount>,</cfif></cfoutput>
  52. Michael Sprague Says:
    @Don - If you want to send me an e-mail with a link to the site you are developing I can look at it and probably help. Use the Contact Project link on the RIAforge site.

    http://cfjqajax.riaforge.org
  53. Garrett Johnson Says:
    Has anyone got the error "G is undefined" when using this. I can see my json being being sent back in firebug but I get this error before anything has a change to render in the grid.
  54. ppshein Says:
    Incredible. I'll use these codes in my project.
  55. udip Says:
    Michael thanks for the awesome grid. I had a quick question, is there any easy way to refresh the grid when I close the modal window? my modal window is used to update the record so when I close it I would like to see those changes on the grid.
  56. Michael Sprague Says:
    @udip - It is possible to refresh the grid when the window is closed. There is an onHide attribute to the window tag. Write a function to refresh the grid, and then call that function in the onhide attribute.

    This is the code that will refresh the grid...

    $("#flexigridid").flexReload({ url: '/url/for/refresh' } ;
  57. Jeremy Says:
    Is there an attribute that like autoWidth="true" that will make the columns autosize to the width of the grid? Thanks! I really like the grid!
  58. sam Says:
    interesting thought
  59. Jeffrey Smith Says:
    Great Tags and great Work!! I have this demo working with a dbase called via a CFC and it populates and the grid functions as demo'd.

    My only problem is weird in that I have 5 items that can be searched. No matter what I do I only the first 3 items show up correct as they are labeled in the grid_column "header". However, the others all show up as their "name" in the Search drop box.

    This is what I used:
       <cf_gridcolumn name="id_anl" header="The ID" hide="true" searchable="true" />
       <cf_gridcolumn name="name_anl" header="Name" searchable="true" />
       <cf_gridcolumn name="idspc_anl" header="Species" searchable="true" />
       <cf_gridcolumn name="idspt_anl" header="Species Type" searchable="true" />
       <cf_gridcolumn name="idgdr_anl" header="Gender" searchable="true" />

    Returns:
    The ID
    Name
    Species
    idspt_anl
    isgdr_anl

    Any thoughts - thank you Jeffrey
  60. Nkonye Oyewusi Says:
    I keepgeeing "Error:Window name not found," despite following the instructions to the letter. Can someone help?I'm trying to build modal windows for a Cf6 application.
  61. Michael Sprague Says:
    @Nkonye - I will answer your question from RIAforge, where you submitted it as an issue. I see the error in the code sample you provided there.

Leave a Reply

Leave this field empty:



Powered by Mango Blog. Design and Icons by N.Design Studio