Using the Telerik RadGrid

Image of Carl Wright

Posted by Carl Wright
on Tuesday, May 08, 2012

The Telerik RadGrid enables you to create sophisticated views of various sources of data stored in your database. The grid is made up of rows and columns, you can define how many rows are displayed and which columns are included. The view of the data you generate, using the grid, can then be exported for additional manipulation in Microsoft Excel or Word.

Performance

It's important to remember that your grid is connected directly to your database and as such complex views of data can take a little while to formulate. For example, if you have thousands of rows representing orders and you want a total value calculated for those rows the database can take a little while to make that calculation. You won't see performance issues too often and usually only when you are performing complicated operations on the grid, the database is quite capable of calculating many operations but at busy times of the day you may find some slowing of the grid.

Filtering

One of the most important functions your grid can perform is filtering. This offers you the ability to locate a group of rows in the database using one or more filters. You can enter filters into one or more of the filter entries at the top of the column:

Image of RadGrid filter

Pressing the button to the right of the filter box will present you with a selection of filter options. Use these to identify how you want to filter the grid using your entered value.

Image of RadGrid filters

You will see a number of filter options to the right, this list will differ slightly depending on the type of field you are filtering, for example if you are filtering a numeric column you will not see the Contains option.

If you wish to find records using the Between option then you should enter the two values into the filter box with a space between the entries, for example if you wish to find Orders with an ID between 100 and 200 enter 100 200 into the filter box then select Between from the dropdown options.

When filtering a column that is represented by a tick or a cross (true or false), you are able to toggle the tick box in the filter row to display either true or false rows, to return the selection to display both true and false records you must choose the No Filter option from the filter options to undo your selection.

Grid Layout

You can easily change the layout of your grid by selecting the columns you wish to see, the order the columns are displayed and their width. Additionally you can select how many rows are displayed, various groups of data as well as any aggregate information for a column.

  • Columns

    To re-position a column in your grid simply hold down your mouse button then drag and drop the column to the position you would like it displayed. Removing a column is simple too, just right click on any of the columns, you'll then see the "context menu" popup. Scroll down to the columns listing and un-tick any columns you don't wish to display in your grid.

    Image of RadGrid columns

    As well as positioning columns you can change the width of a column to allow more data to be displayed. To change a column width you must position your must between two columns, until the pointer turns from a four point arrow (indicating that you can move the column) to a two point arrow. Hold your mouse down and drag left or right to change the width of the column to the left.

  • Page Size

    You can change the number of rows that are displayed in each page of your grid by setting the page size, this option can be found at the bottom of the grid. Keep in mind that the larger your page size the slower your grid will load.

    Image of RadGrid page size
  • Grouping

    You may wish to group certain columns of data together in your grid, for example you may like a grid with all customers grouped by their order status. To group by one or more columns of data simply drag the column to the area above the grid identified with the text "Drag a column header and drop it here to group by that column". To remove a grouping you should drag the column back to the header row.

    Image of RadGrid group
  • Sorting

    To sort your grid by any one column you can simply click the column once. You will see an arrow pointing up or down to indicate that your grid is being sorted in an ascending or descending order, to change the order click the column again.

  • Aggregates

    It's possible to add aggregated values to your column, these appear at the foot of the column. You can use aggregate functions such as Sum, Count, Avg (Average) etc. To display an aggregate value for a column simply right click on the column header and scroll down to the Aggregates fly-out. You can select from any of the aggregate functions displayed for that column type. The function is applied to the whole filtered grid, not just the page you are currently looking at, so if you have 20 pages of 20 rows and choose to apply a sum function to a column this will apply to 400 rows.

Saving Layouts

You can save any of your grid layouts for future use. With the exception of aggregates all settings can be saved on a per user basis. To save your layout you should enter a name for the new layout in the text entry shown in the top right of the grid screen.

Image of Save Layout

You can make changes to your layout and re-save it using the dropdown list and selecting the previously chosen name. Pressing the reset button will return your grid layout to its original setting and will return all of the available columns.

Exporting Data

It's easy to export your grid data to a Microsoft Excel or Word document as well as a CSV file. Only the data that is displayed in the current page of the grid will be exported. If you want to export all of the data you will need to select the appropriate page size at the foot of the grid, in the case of the example below you will see there are 826 rows but if you export this page of data you will only export 20 rows, to export it all you will need to change the page size to 826.

Image of RadGrid Export
Child Rows

You may be able to drill down some of the rows in your grid. If you can, you will see an arrow to the right of the grid row as shown below.

Image of RadGrid child rows

By clicking the arrow you will expand the row to display related child rows (such as an address for a customer or a list of ordered lines for an order).

1 comment
Thenmozhi
6/20/2012 1:23:58 PM
When i group the grid column horizontal scroll bar not appearing.

Post a Comment

Full Name
Email Address
Website
Comments
Real Time Analytics