Ajax-based CFGRID and IE issue

I've been working with a user on this issue and since it involves CSS and IE (two things I try not to be familiar with), I figured I'd blog it to see if one of my readers can help.

Here is the gist of the problem. The user has a cfgrid, ajax-based (well, the new fancy HTML grid, in this demo it won't use HTTP to load it's data), that is editable. In IE something odd happens.

When you click and edit a cell, the cell goes blank. But if you click on another row, you can see your data. If you click back, and try to type, your data is there, so you don't lose anything. When you submit, the mods are there as well.

Here are some screen shots. First, the table before anything is done:

Now here it is, blank, right after I finished modifying it:

And here is a shot with me selecting another row. You can see now that the data is there:

My guess is that this has to be a simple CSS/IE conflict. Anyone else run into it? Anyone have a possible solution?

Comments

Dave Byers's Gravatar This'll be a bad first "me too" comment, btu I've been beating my head against my monitor for a week now trying to figure out where the CSS issue is here.
# Posted By Dave Byers | 8/5/08 2:20 PM
Andy Sandefer's Gravatar Well I'm not sure if this is really a solution. It is more of a work around. Although I love the new ext grid I've had nothing but inconsistencies and problems dealing with it in terms of edit capabilities (and some event driven style issues with IE - on column resize or auto-resize with double click on the column header). At any rate I just create a modal cfwindow based on the selected record in the grid and the user clicks a button to save which in turn fires up a proxy to handle the update (or insert) from the cfwindow's form to the database. I'm sorry, I know it is not the answer you're looking for but I truly believe it is the best approach to add/edit functionality.
# Posted By Andy Sandefer | 8/5/08 2:21 PM
Dave Phipps's Gravatar Although the cfgrid is very convenient to setup I found in a recent project that the power available was hampered by the slightly unreliable nature of it (and the size of all those js files). I now use a jquery plugin called jqGrid (http://www.trirand.com/blog/) it is not as powerful as cfgrid but I have managed to do pretty much all of the things I needed to do, such as updating/editing/sorting rows.

If you need any pointers/example code just give me a yell.
# Posted By Dave Phipps | 8/5/08 4:07 PM
Jared Shields's Gravatar The problem is 100% in the CSS of the grid. I submitted this problem to Adobe, but of course I'll never hear back on that...

SOLUTION:

Open the EXT-ALL.CSS file (traditionally located at /CFIDE/SCRIPTS/AJAX/RESOURCES\EXT\CSS/)

Search the file for "//". You should find roughly 6 lines that look similar to this "//color: white;". Clearly somebody mixed up their comment syntax and incorrectly commented those lines out; thereby, NOT commenting them out.

Go ahead and change the prefix on the line from "//" to "/*" and end the line with "*/".

Refresh and your problem should be solved. :-)

Note, this problem was NOT resolved by 8.0.1 so everyone will need to update this file.

Cheers.
# Posted By Jared Shields | 8/5/08 4:39 PM
Christian Gurney's Gravatar I'm going to look at Jared's solution closely because I thought I was the only guy on the planet who couldn't solve this problem!

Great sleuthing, BTW.
# Posted By Christian Gurney | 8/5/08 5:42 PM
Mat Evans's Gravatar nice one!
i've been looking at the problem for about a year!!!

there's a couple of other little caveats with the grid too, mostly all solvable with css.

Mat
# Posted By Mat Evans | 8/6/08 3:38 AM
Paul's Gravatar Excellent! My thanks to Jared Shields and to Ray Camden for going out of his way to help find a solution to this problem.
BTW, I believe you need to surround the offending lines with /* */ as follows:

.x-grid-row-selected td, .x-grid-locked .x-grid-row-selected td{
   /*color: white;*/
}


.x-grid-row-selected span, .x-grid-row-selected b, .x-grid-row-selected div, .x-grid-row-selected strong, .x-grid-row-selected i{
   /*color: white !important;*/
}

.x-grid-row-selected .x-grid-cell-text{
   /*color: white;*/
}

.x-grid-cell-selected{
   background-color: #316ac5 !important;
   /*color: white;*/
}

.x-grid-cell-selected span{
   /*color: white !important;*/
}

.x-grid-cell-selected .x-grid-cell-text{
   /* color: white;*/
# Posted By Paul | 8/6/08 9:44 AM
Jared Shields's Gravatar No problem :-)
# Posted By Jared Shields | 8/6/08 10:42 AM
Brian's Gravatar I looked at my EXT-ALL.CSS out of curiosity on my CF8.01 install on my local XP-based laptop and the file does not have the extra "//" in it. I even found the specific references Paul cites. I'm not trying to edit my grid using the grid itself, but why is mine fine? I may have done a fresh install. Did you all remove the old versions before loading 8.01?
# Posted By Brian | 8/6/08 3:05 PM
Jared Shields's Gravatar Excellent question! I have no idea why youre didnt have the "//".

The installations that I've confirmed it on are 8.0 and 8.0.1 (That was upgraded).

Can anyone else confirm this?
# Posted By Jared Shields | 8/6/08 7:50 PM
Dave DuPlantis's Gravatar I have CF 8.01 installed on my XP Pro desktop, a fresh install, and I see the incorrectly-commented lines in my EXT-ALL.CSS file.
# Posted By Dave DuPlantis | 8/7/08 8:05 AM
Raymond Camden's Gravatar For those who say they have 801, don't forget that past 801 there was a CHF (Cumalative Hot Fix) and a few other post CHF hot fixes as well.
# Posted By Raymond Camden | 8/7/08 8:29 AM
Brian's Gravatar I just added the Cum Hot fix 1 and the hot fix related to the grid and they affected one CSS, but not this one.
# Posted By Brian | 8/7/08 10:40 AM
Brian's Gravatar Found why mine was different - Dreamweaver issue. I opened the CSS directly and get:

//color: white;

but if I use Dreamweaver to follow the link in my code, which I did before, I get:

background-color:#316ac5 !important;color:white;

Not sure how that translated.
# Posted By Brian | 8/7/08 10:51 AM
Raymond Camden's Gravatar Ugh - a good reason to not use Dreamweaver.
# Posted By Raymond Camden | 8/7/08 12:12 PM
Jared Shields's Gravatar So ray, gonna pull some strings to get that issue corrected as a Hotfix ???
# Posted By Jared Shields | 8/7/08 6:41 PM
Ryan's Gravatar Any one else having issues when trying to resize the columns, by dragging the dividers between the column headers. if you leave them alone, they are fine, but once you try to resize them, the headings go haywire, and are no longer lined up over the columns.
# Posted By Ryan | 8/13/08 9:54 PM
Steve's Gravatar Resize DOES NOT work in IE7... (but notice you do see the ellipse [the three dots] in IE, not in FF). Anyone have a fix for that issue?
# Posted By Steve | 8/21/08 2:04 PM
Paul's Gravatar Raymond: you were so much help with the IE display issue, possibly you can shed some light on another grid problem. I have a complex page with multiple sections. Each section contains two editable grids. When the page loads the bindOnLoad property of each grid is set to false to speed the page load up. Only when the user clicks to open a section are the grids displayed and the data loaded with ColdFusion.grid.Refresh(). So the page should load fast, but the grids slow the page load down to a crawl. I don't understand why the grids slow the page down so much when no data is being loaded, but if you comment out the grids the page is smoking fast. Any ideas what might cause this or how to work around it would be appreciated.
# Posted By Paul | 8/25/08 3:50 PM
Brian's Gravatar I see the same slowness in IE6, but much better in FireFox, unfortunately my client is on IE 6. I believe I've heard it is related to how IE is handling the Javascript, especially if you use it nested in cflayout tags, which I do. Are you using IE 6 or 7? Are you using cflayout tags? I would also be interested in Ray's thoughts on how we can improve on this awful performance hit.
# Posted By Brian | 8/25/08 4:03 PM
Paul's Gravatar My Client is on IE6 as well, and my grids are nested in cflayout tags.
# Posted By Paul | 8/25/08 4:14 PM
Brian's Gravatar My client will probably not even accept my ColdFusion solution because of this. So much for working on the bleeding edge. We're doomed unless Ray can help us.
# Posted By Brian | 8/25/08 4:26 PM
Raymond Camden's Gravatar So guys- a bit of a quick response. It's late here and I spent the last few hours working with my wife on her math homework. My answer now may not be the "best" so please take it with a grain of salt.

My general answer is - if the built in ajax ui stuff is not working well, then I'd probably not use it. Remember that the built in Ajax UI stuff is simply wrappers to other libraries. Adobe did their best to try to make it as easy as possible, but in doing so, also had to cut some corners. This I think is fair. But it means that if the out of the box UI stuff doesn't work well, then you should consider rolling your own.

Doing so does NOT mean you are turning your back on CF8 and Ajax. There are still plenty of NON-UI Ajax things that you can - and should - continue to use.

Does that make sense? Not trying to pass the buck here of course.
# Posted By Raymond Camden | 8/25/08 10:33 PM
joe's Gravatar So we pay thousands of dollars to buy our own copy of CF8, or pay extra for special hosts that uses it, so that we can use the new features and then we're supposed to just deal with it when parts of it don't work correctly? Really? How disappointing...
# Posted By joe | 8/26/08 8:48 AM
Raymond Camden's Gravatar @joe: Absolutely not. My recommendation was just that - a recommendation. I don't speak for Adobe. The PROPER thing to do when you find a bug is to contact Adobe for support. Yes, this costs money, but if you find a real bug you are NOT charged for it.

CF - like every other software product in the world - has bugs. Nothing will change that. If you follow the procedure to report bugs to them to help them fix it however it will lead to them being able to fix it.

I have - from time to time - recommend folks not using the Ajax UI stuff if they have more advanced needs. This has nothing to do with any bugs. More it's the understanding that the tags CF built can't cover each and every possible use case. That would be impossible. For folks who are new to Ajax, the tags in CF8 can be a godsend. But for those who are more comfortable with other libraries, ike jQuery UI, then it may make more sense to use them instead.
# Posted By Raymond Camden | 8/26/08 8:55 AM
Paul's Gravatar Raymond: Of course CF has and always will have bugs, thats a given. In this case, I can't really say this is a bug since the grids work exactly as advertised. So I don't see how I can report this as a bug. However, the performance overhead makes them impossible to use in a production environment so I can see Joe's point as well. Just to say don't use the Ajax UI components when we have all paid for them does not seem right either. And its not just in some obscure use case. Here is a simple, generic piece of code to demonstrate:
<cftimer type="debug" label="50 Grid Check">
<cfform name="test">
<cfoutput>
   <cfloop from="1" to="50" index="i">
      <cflayout type="vbox" name="layout#i#" style="width:100%; height:100%; display:inline;" >
         <cflayoutarea title="User Profile" selected="true" name="userprofile#i#"style="height:80%; width:100%; display:inline;" >
            <cfgrid format="html" bind="cfc:customer.getUserInfo({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},'#i#')" onChange="cfc:customer.updateUser({cfgridaction},{cfgridrow},{cfgridchanged},'#i#')" pageSize="1" bindOnLoad="false" width="650" autowidth="false" name="userprofile#i#" >
                                       <CFGRIDCOLUMN NAME="UserID" HEADER="User ID" WIDTH="1" display="False">
                                       <CFGRIDCOLUMN NAME="duReportedUserID" HEADER="ID" WIDTH="35" >
                                       <CFGRIDCOLUMN NAME="duFirstName" HEADER="First Name" WIDTH="65" textcolor="black">
                        <CFGRIDCOLUMN NAME="duLastName" HEADER="Last Name" WIDTH="65"/>
                        <CFGRIDCOLUMN NAME="duTelNo" HEADER="Phone Number" WIDTH="65"/>
                     <CFGRIDCOLUMN NAME="duEmail" HEADER="EMail" WIDTH="65"/>                  
            </cfgrid>
         </cflayoutarea>
      </cflayout>
   </cfloop>
</cfoutput>
</cfform>
</cftimer>

On my server the debug says [280ms] 50 Grid Check
But the page actually takes minutes to load, IE or FireFox.
Take out the grids and it loads in seconds. So this does seem to be a performance problem with the grid itself.
# Posted By Paul | 8/26/08 12:07 PM
Raymond Camden's Gravatar Performance issues can be submitted as bugs as well Paul.

However - I'd say 50 grids on a page being slow isn't a bug. Just like putting 50 large JPGs on a page would slow it down, I'd say overuse of _any_ UI item would cause a slow down. Now it you saw significant slowdown with 5 or less grids, which is a much more reasonable #, then I'd definitely say we have a problem.

I noticed in your earlier comment you mentioned 2 grids slowing the page down to a crawl. What is the total time to load when using 2 grids?
# Posted By Raymond Camden | 8/26/08 12:12 PM
Raymond Camden's Gravatar Using 5 grids, the page loaded very quickly, but it was a local host test. I checked yslow. The results were:

Empty Cache: 591K (css+js+cs+html+image)
Primed Cache: 16.1K

So the non-primed cache is large. This represents all the stuff loaded to support the ajax items. This is large, yes. You can get smaller #s if you use jquery. Again though folks the idea here is trade offs. You get the convenience of ease of use but the trade off is the impact on the initial download.
# Posted By Raymond Camden | 8/26/08 12:22 PM
Paul's Gravatar Raymond: I did not make myself clear, the 2 grids were being created in a loop through many users, so it was 2 X the number of users, which could be quite a few. Performance with 5 grids is perfectly acceptable, I just ran the code sample with that number and it came back in a fraction of a second. I guess I just expected that if you did not load any data into the grid that it would be possible to create a large number of grids quickly, but that does not seem to be the case. What I was trying to do was load the page with hidden, empty grids that would then load their data using ColdFusion.grid.refresh when the user chooses one.
# Posted By Paul | 8/26/08 12:58 PM
sneha's Gravatar Can someone tell me how to use url in cgfrid onChange attribute?

For eg:
<cfgrid format="html" name="campaignGrid"
bind="url:http://mysite/cfc/cfcname?method=....etc";
onChange="url:http://mysite/cfc/cfcname?method=editData&grid...={cfgridaction}&gridrow={cfgridrow}&gridchanged={cfgridchanged}"

Although url in bind works...the onChange doesn't seem to work this way.
I had onchange="cfc:cfc.cfcname...." before but some prob with my cfc path that i couldn't resolve. So i need to get this working this way. Can someone point out whats wrong.
# Posted By sneha | 9/12/08 7:07 PM
Raymond Camden's Gravatar Try a URL w/o a full path. url://cfc/cfcname/etc
# Posted By Raymond Camden | 9/13/08 1:24 PM
sneha's Gravatar Thanks for the reply. I tried
onChange="url://cfc/cfcname.cfc?method=editData&gridaction={cfgridaction}&gridrow={cfgridrow}&gridchanged={cfgridchanged}"
But didn't seem to help.
After double clicking & editing the cell i do see the red indicator in the corner of the cell, but when page is refreshed, i don't see the change anymore. I don't get any errors either to figure out where the problem is.
Here is the editData fn from the cfc:
<cffunction name="editData" access="remote" output="false">
<cfif isStruct(gridrow) and isStruct(gridchanged)>
<cfif gridaction eq "U">
<cfset colname=structkeylist(gridchanged)>
<cfset value=structfind(gridchanged,#colname#)>
         
<cfquery name="edit">
   update [table]
   <cfif isNumeric(value)>
    set #colname# = #value#
   <cfelse>
    set #colname# = '#value#'
   </cfif>
    where campaignID = '#gridrow.campaignID#'
</cfquery>
</cfif><!---end <cfif gridaction eq "U"> --->
</cfif><!---end <cfif isStruct(gridrow) and isStruct(gridchanged)> --->

</cffunction>

Like how i had to include returnFormat=json in the bind url, should the format be specified in the onChange url too?
# Posted By sneha | 9/13/08 2:41 PM
Raymond Camden's Gravatar The format is wrong. it isn't url://, but rather url:URL here, relative,

So I'd assume you want

url:/path/to/CFC

or

url:cfcinsamefolder.cfc

To include the returnformat, just add it as a query parameter.

url:my.cfc?method=dosomething&returnformat=json
# Posted By Raymond Camden | 9/13/08 5:53 PM
sneha's Gravatar Sorry..that was a typo on my part.
I tried url:/cfc/cfcname.cfc?method=editData&gridaction={cfgridaction}&gridrow={cfgridrow}&gridchanged={cfgridchanged}&returnFormat=json
I also moved cfc to same folder as this page & tried
url:cfcname.cfc?method=editData&gridaction={cfgridaction}&gridrow={cfgridrow}&gridchanged={cfgridchanged}&returnFormat=json

It still wouldn't work..
# Posted By sneha | 9/13/08 6:32 PM
sneha's Gravatar Just an addition to my earlier comment:
I used firebug & it showed some error msg while i tried to edit the grid. Here it is:
_251[i] is undefined
if(!_251[i].length){.....

in cfajax.js (line 147)

Not sure what it means.
# Posted By sneha | 9/13/08 7:23 PM
Raymond Camden's Gravatar Shoot. I'm getting that too. I know I got it working before because when I was testing this issue (this issue as in the original blog entry), I had looked at what was sent to the server. Yet a simple test on my own server now is failing again. The only difference in my new test is that the original data is from the remote server, and my first test the data was embedded directly on the page.
# Posted By Raymond Camden | 9/14/08 9:30 AM
Paul's Gravatar Ray: you were so helpful in resolving the original problem, here is another (probably CSS) cfgrid issue in IE.
I have a cfgrid that displays in a cfwindow. Looks perfect in FireFox, but when it loads in IE the headers are all messed up. Their text overlaps the columns, they are not aligned properly, etc. Then when you mouse over them they fix themselves. EXT, css and IE related to be sure, but I have no idea how to fix it.

Thanks in advance for any insight.
# Posted By Paul | 11/24/08 4:17 PM
Raymond Camden's Gravatar About the only insight I can give is to not use IE. ;) Sorry, I'm on a Mac and only use IE on my Windows box when I havew to.
# Posted By Raymond Camden | 11/26/08 4:41 PM
AlexS's Gravatar For those who have the header resize problem within ie 6, i've finally found where the problem is, apparently the cfgrid html format cannot be nested into a standard html table. Hope this helps
# Posted By AlexS | 12/19/08 4:00 AM
Paul's Gravatar If you set autowidth="false" and grid_width to the sum of the width of the columns plus a pixel (for the column separators) you can get the columns and headers to line perfectly. Hope this helps.
# Posted By Paul | 12/19/08 11:23 AM
Dylan  Miyake's Gravatar Ray,

I have an interesting one here. I'm working on an app that uses CFGrid pretty extensively, with ColdFusion.navigate used to move from page to page.

One thing I noticed that when .navigate is used, the grid objects are not destroyed, so I googled about in the Ext forums and figured out how to destroy them.

But then I noticed that upon multiple page refreshes, IE would start to fail. It appears as if cfgrid.js is appending *two* style sheets to the header with each cfgrid that's created, one with the proper "id-cssrules" (which gets cleaned up by Ext when the grid is destroyed), and one without the suffix (which just sits there in the header), until you hit the magic number of 30 and IE dies.

To work around this issue (temporarily), I've changed line 71 in cfgrid.js to read:

Ext.util.CSS.createStyleSheet(_264.styles, 'foo');

and I'm manually killing the style sheet after destroying the grid:

Ext.util.CSS.removeStyleSheet('foo');

It's pretty easy to see the two stylesheets generated by Ext and cfgrid.js in Firebug, and the IE 30 style sheet limit is documented here:

http://support.microsoft.com/kb/262161

Seems like a pretty hacky workaround to me. Have you (or any other readers of this blog) run into this?

Regards,

Dylan
# Posted By Dylan Miyake | 1/21/09 8:50 PM
Raymond Camden's Gravatar Well, I don't use IE, so I wouldn't see it. I can say though that it seems like you have not only found a bug but a solution, so _please_ log it with Adobe:

http://www.adobe.com/go/wish
# Posted By Raymond Camden | 1/21/09 8:55 PM
Dylan  Miyake's Gravatar Ran into another interesting issue as I was trying to track down the memory leaks in the application we're building. I profiled and profiled under IE (necessary evil) to figure out what was causing the massive memory bloat, only to find out that Skype's IE plugins were the culprit (which is why we couldn't find them in Firebug)

http://www.actionscript.org/forums/showthread.php3...

If anyone else is using Flash and the CF Ajax functionality, seeing IE get more and more bloated, check to see if the Skype browser add-ins are the culprit. An application that routinely ate 1GB+ of memory is now down to 80MB or so (still too much, but much more manageable).
# Posted By Dylan Miyake | 1/23/09 5:14 PM
Chris Ulrich's Gravatar Dylan -

I tried your fix but it didn't work for me. In all fairness, I'm not sure if I'm properly destroying the grids.

I've got a CFLAYOUT structure with menu on the left and "content" on the right. For me, if I click one link on the left that loads a CFGRID on the right, and repeat 13 times, I'm dead. I've added:

javascript:Ext.util.CSS.removeStyleSheet('foo');

to the front of each menu link, such as:

<A href="javascript:Ext.util.CSS.removeStyleSheet('foo');ColdFusion.navigate('rightside.cfm?id=support.faq.edit','supportright');">Maintain FAQ's</A>

This had no effect (and I did change the cfgrid.css in inetpub\wwwroot\cfide\scripts\ajax\package)

Is there a better way to destroy the grid that would make this work?

Thanks
# Posted By Chris Ulrich | 2/9/09 8:38 AM
Chris Ulrich's Gravatar Interestingly, if I do the same thing in FF and reload at a "reasonable pace" - every few seconds, memory usage goes up very slightly - maybe 10k/hit.

HOWEVER, if I go click happy, it leapfrogs 2MB per hit, apparently not having enough time to clear (whatever) from memory before the next instance loads...

C'mon IE / Adobe ... play nice! While I love CF, Adobe really should be testing & fixing deeper. If people can come up with work-arounds, they should fix the code.
# Posted By Chris Ulrich | 2/9/09 8:50 AM
Dylan Miyake's Gravatar @Chris:

Did you also change the cfgrid.js? That's where you assign the name to the stylesheet, so you can destroy it later. I also have a series of hacky workarounds for destroying grids if you're interested.

Dylan
# Posted By Dylan Miyake | 2/12/09 6:13 PM