Getting Started with Server Mode for ExpressQuantumGrid

In my previous blog post I went over some of the performance benefits of the new “Server Mode” feature for the VCL grid from DevExpress. In this brief post, I’ll go over the steps needed to get started using this new feature. In this example I’ll be targeting Microsoft SQL Server using ADO.

You’ll want to start off by creating a new VCL Forms Application. Add a TcxGrid control to the form. Right-click the default grid level to invoke the level’s context menu. From there, create a new Server Mode grid view.

Next, drop a TADOConnection component on the form. It can be found in the dbGo section of the Tool Palette, or by using he Search box.

With the TADOConnection component selected, configure it by setting LoginPrompt to False and clicking the elipsis next to ConnectionString to configure the underlying connection.

As I mentioned, in this example I’m targeting Microsoft SQL Server. The project source linked at the end of the blog post contains SQL scripts for creating a sample table and filling it with data. Use the Data Link Properties dialog to configure the connection.

With the connection configured, locate the TdxServerModeADODataSource on the tool palette and drop it on the form. The “Server Mode” datasource is responsible for taking the needs of the TcxGrid view and creating SQL queries that return only the data necessary to render the results on-screen.

The data source only has a few properties. Start off by setting Options.SQLAdapter to “MSSQL Adapter”. If you don’t set the Options.SQLAdapter, trying to configure other properties will let you know you’ll need to assign that property first. Next, set the Connection, after which you can use the drop down lists to select your TableName and KeyFieldNames.

With the datasource setup, we’re in the home stretch. Select the “Server Mode” view by clicking the “cxGrid1ServerModeTableView1″ UI element on the TcxGrid control. With the view selected, expand the DataController node in the Object Inspector and assign the DataSource property.

Right-click the “cxGrid1ServerModeTableView1″ UI element on the TcxGrid control and click “Create Missing Columns” to have the grid automatically create the columns found in the underlying data.

And that’s it! Running the application will leave you with a “blazing-fast” grid capable of loading, sorting, grouping, and filtering millions of rows of data.

You can download the Delphi source code and SQL scripts here.

8 thoughts on “Getting Started with Server Mode for ExpressQuantumGrid

  1. Louis Kleiman

    This sure seems to me to be very limited based on what I see in this post. Apparently, I cannot specify the query that the grid actually displays. I can only specify a table and the grid handles the rest. This means no calculated fields, no joins, …. It also means that I have no control over the DataSet being displayed. This, in turn, means that I will have to forgo editing of the displayed data in most cases. I’ll go take a look myself, but I don’t see how the above facts aren’t true. Plus, apparently, I can’t use a TClientDataSet even though a CDS could be set up to allow SQL passthrough to the server via CommandText. I understand the need for the DataController to issue and rewrite SQL in order for this functionality to work. I think it is great work. I am just disappointed that it isn’t a more generic solution. I would have thought that instead of just taking a TableName, the DataController would have been able to take the complete SELECT statement behind the current DataSet and use that to perform the necessary work. I’ll have to take a look at creating my own ServerModeDataSource.

    Don’t get me wrong, I really do appreciate the work. DevEx makes me look good.

    1. nwoolls

      One way to overcome some of these limitations may be to use SQL Views, if your server supports them. I tested creating a view in SQL Server that returns my LotsaRows table with calculated fields and TcxGrid with “Server Mode” seemed to handle that just fine.

      1. Ron Grove

        That’s great if you’re in control of the database. I’m not in such a fortunate position. When I saw I couldn’t use my own queries the value of the new feature went almost to nil… :-( Should be great for people that do have the ability to create views, though.

  2. Franky Brandt

    Trying out the server mode right now; looks neat but as said above i was puzzled that there is no ‘SQL’ property where i can put my sql code including wildcards and joins instead of just picking a table name in the dxServerModeDBXDataSource; hopefully this will be added later on.

  3. Franky Brandt

    Well i have been doing some testing in a demo application i made today and i must say it is blazing fast indeed.
    In my demo i connect to my firebird database in 3 ways, dbexpress with TClientDataset, Fibplus and dxServerModeDBXDataSource.

    The table i get data from has 100558 records and opens in 112 and 111 seconds with TClientDataset and Fibplus respectively and in 0.28 seconds with dxServerModeDBXDataSource.

    So that is a terrific result indeed.

    Unfortunantly this means i would have to change my whole application from fibplus to TSqlConnection, which will take a lot of work but it looks to be worth it.

    1. Louis Kleiman

      Your CDS is, I believe fetching all the records. Try setting it up to only fetch on demand and set the packet size to something reasonable (100?). There are all kinds of trade-offs here, but the fact is that this basic design lets your grid drill straight through to your database and issue re-written SQL. It is certainly cool, but if you actually do anything with your datasets in your application, then it will break or bypass much of what you do.


Leave a Reply to Louis Kleiman Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>