Sunday, October 26, 2008

Super Useful Tips on Using DevExpress ASPxGridView

I've been using DevExpress's ASPxGridView on a fairly big ASP.Net project for the past few months. When I started using it, I was really frustrated. The documentation was written more like a class reference guide and the tutorials were fairly basic in nature.

The real MEAT of the controls didn't seem to be there - all this great potential but where?

The Community forums was a great place to look for details but as with many communities, it's hard to find all the answers. 

Hopefully, this post will help identify some of the areas where developers may be having some problems:

Fixing Edit Forms
1. Edit Form Column Layouts
The ASPxGridView lets you do direct "form" editing but when you first do it, the boxes usually go two per line. To resolve this, add
                              <SettingsEditing EditFormColumnCount="1" />
right under the grid definition.

2. Changing Edit Captions
You have a column that is titled Years but in the edit form, you want it to say "Years working for company". Within the column definition, add
<dxwgv:GridViewDataTextColumn FieldName="Years" Caption="Years"/>
          <EditFormSettings Caption="Years working for the company " />
</dxwgv:GridViewDataTextColumn>


Grouping Grids
The ASPxGridView lets you group the grids automatically.

1) Call grid.ExpandAll( ) right after the DataBind (or the Page_Load) to automatically open the groups (by default, they are closed)

2) The Group header starts by showing the name of the Group a colon and then the name. In the Grid definition, add"
Settings-GroupFormat="{1} {2}"

Commands
One thing I didn't like about the Grid View was that it would add New/Edit/Delete buttons on each row. Why show New on each one? I originally put a hyperlink on the top of the grid but instead, I've started to use the HeaderTemplate option instead.

Here's my initial Column set:
                    <Columns>
                        <dxwgv:GridViewCommandColumn VisibleIndex="0">
                            <NewButton Text="New" Visible="false">
                            </NewButton>
                            <EditButton Text="Edit" Visible="true">
                            </EditButton>
                            <DeleteButton Text="Delete" Visible="true">
                            </DeleteButton>
                            <HeaderTemplate><dxe:ASPxHyperLink ID="lblNew" runat=server Text="New" Font-Underline=true Cursor=pointer><ClientSideEvents Click="function(s,e){officers.AddNewRow();}" /></dxe:ASPxHyperLink></HeaderTemplate>
                        </dxwgv:GridViewCommandColumn>

The end result looks like this


Grid Form Validation
You can easily make a field mandatory in a grid by setting the IsRequired property to true. But there are two gotchas with this. By default, this puts a little exclamation mark by the field when you hit the Update button. The ErrorText property is then put into the tooltip.

Set the ErrorDisplayMode property to Text instead of the default which is ImagewithTooltip.

Another way to better manage this process is to put the validation settings directly into the code instead of the property settings.

loCol = grid.Columns(0)

            With locol.PropertiesTextEdit.ValidationSettings
                .RegularExpression.ValidationExpression = regexp
                .ErrorDisplayMode = DevExpress.Web.ASPxEditors.ErrorDisplayMode.Text
                .RegularExpression.ErrorText = msg
                .RequiredField.IsRequired = True

            End With

The above code also shows one of the other cool tips - instead of trying to validate the text after, by setting the ValidationExpression property, the input can be immediately validated via Regular Expression.

Column Widths
By default, the ASPxGridView will resize the widths based on the content. Some of our users found this disorienting when they edited the grid - because it would constantly change. Solution? Explicitly set the widths of each column.

I'm sure there are a lot more and some of the above are likely pretty obvious but I wish I had known about them when I first got started. I'll be adding to this post (or creating new ones) as I move forward.

The other cool part about devExpress is that a number of their developers are on Twitter, making it easier to find them and get help.


New Rule: Don't develop with Fingerprint Reader!

Who would have thought developers fingers could cause crashes?

I was working with my VS 2008 ASP.Net application and added some javascript to my default.aspx page when I started to get TypeLibBuilder crashes. WTF? Maybe it was my code --- maybe there was something going on in VS 2008 that I was missing. I shrugged and continued - because after all, when you get weird Windows crashes and you're working on a project, you do the obvious: restart your machine, pray to the Seattle gods and continue on your way.

Then I searched for it -

Big Problem Solved - No More TypeLibBuilder.exe Crashes!

Whoa! Killed DpAgent.exe in my Task Manager and no more errors.

Apparently my new MS Fingerprint Reader doesn't like JavaScript! Who knew?

Saturday, October 25, 2008

FoxShow #59: Profiling and Refactoring

The latest episode of The FoxShow features one of my sessions from Southwest Fox 2008: Profiling and Refactoring, a discussion on how to refactor and how the VFPX Code Analyst can help.

This session was given twice : this was the second time around. It was a good discussion including a back and forth on the benefit of comments. I, of course, took the controversial position that all comments should be banned from code except when they explain WHY something was done.

Thursday, October 23, 2008

The Fox Index

Here's a fun little piece from Southwest Fox 2008 where Ken Levy floats the idea of the Fox Index, a great use of those remaining copies of Visual FoxPro and then of course, Craig Boyd takes it one step further.



FoxShow Extra: Morning discussion with Alan Stevens on Agility

One of the great things about Southwest Fox was the open discussions that were had almost every minute. Thankfully, some discussions and "discussers" let them be recorded.

Here's a discussion Alan Stevens and I had one morning about his sessions on Agility and Ignorance as well as XML handling - a little FoxShow extra. It's short (about 16 minutes) but fun.

Enjoy!

Tuesday, October 21, 2008

Looking for VFP work?

If you're in the market for working full-time for a vertical market (transportation industry) company with a product family written in VFP 9 with lots of add-on modules (http://www.mtihorizon.com), and a migration path to SQL Server, drop me a line at amacneill @ meltech.com.

Will: communicate with customers regarding support problems, develop new solutions based on client needs, enhance product in both VFP and web environments

Requirements: VFP 9 experience, enthusiasm, good OOP background, DBF/SQL
Nice to have: C#, web development, EDI experience, mobile communication, transportation industry

Location: anywhere but need to be available during the regular day (EDT) - we do lots of remote stuff (thank you SourceOffSite!)

If interested, drop me a line at amacneill @ meltech.com.

Monday, October 20, 2008

A Little Performance Art...

A little performance art piece from Southwest Fox...(if it says unavailable, it's still being processed)




Saturday, October 18, 2008

SWFox: Evil Mastermind Wins Again!

One of the great sponsor giveaways at Southwest Fox was a 5-user license of SourceGear's Fortress. I've used Vault and Fortress but still stick with Source OffSite as our main development is handled through SourceSafe. Both work great with VFP. But the best part was in the conference bag: Evil Mastermind 2nd Exciting Issue!

Best quotes:
"You're a sales guy...if anyone understands evil, it's a sales guy"

"I want...I want...I want....and I want 5000 t-shirts!"

"We've got lots of masterminds using our products...I'm sure at least some of them are a little bit evil...I guess"

Kudos to Eric and the SourceGear team for another fun issue and great job, Southwest Fox team (was that you, Rick?) at getting the great swag!

SourceGear | Fortress

SW Fox: Why NOT Show your own apps?

One of the sessions that I didn't get to attend last night was the "Show us your apps". I think that session would have been really interesting.

Many of the attendees I spoke to were fairly shy about their own FoxPro applications. They would talk about it (as it is their "baby" so to speak) but when asked about specific features that they should show, they seemed to shy away.

That's unfortunate - because I don't think I've ever seen a single FoxPro app (with the possible exception of some purely framework-based apps) that hasn't included a unique feature or hook.

That's one of the reasons I'm particularly excited about Cathy Pountney's session about customization vertical market apps.  Only problem is that it's on right when I've got to get ready to leave. I think I'll have to corner her separately for a quick interview.

But back to my point, one my client apps is an application that was ported from DOS and brought kicking and screaming up to Windows and now finally over to SQL. It has TONS of Bad features (filtered grids, etc). BUT...it also includes some great features: built-in alerts, custom business rule validation.

So when asked to show my apps, I wouldn't show the bad stuff (well, I might to show that it exists everywhere) but the really cool stuff.

Everyone's got some kind of cool in their applications somewhere...why not show it?

The FoxShow #58: the VFPX Meeting

At Southwest Fox last night , we had a VFPX Meeting (that was also screencast over uStream).

The meeting went on for just under 2 hours but a lot of great ideas were thrown about, including ways for others to get involved, without having to code (something that many seemed to like).

I recorded it all for the FoxShow and while the audio may be iffy at times, it's a great listen!

Enjoy!

The FoxShow

Tweets from Southwest Fox 2008

While you won't necessarily see every post from Southwest Fox until maybe a few days after the show, you can keep up with it on Twitter.

Here's the hash tag and the search link: #swfox - Twitter Search

A really great conference with lots of fun stuff going on around here and the first real conf day (aside from pre-cons) is just over. 

Prepping for sessions, I only got to see one session which was Alan Steven's Agility. I'm going to put my notes up in a blogpost but I actually took my notes using Mindjet's MindManager and thought it would be cool to take them and also post them here.

 (this is a sample of out of the box MindManager exports)

More to come...