Ticket S19661
Visible to All Users

ASPxGridView - add an ability to provide a sorted data source to the ASPxGridView and prevent the control from sorting data itself

created 17 years ago (modified 10 years ago)

What I need is an event when I click on a header.
I was just evaluating and testing the Teleriks gridview and they have an event called SortCommand.
I'm needing just about the same as this:

C#
    protected void RadGrid1_SortCommand(object source, GridSortCommandEventArgs e)         {             if ("Name".Equals(e.CommandArgument))             {                 e.Canceled = true;                 GridSortExpression expression = new GridSortExpression();                 expression.FieldName = "Name";                 switch (e.OldSortOrder)                 {                     case GridSortOrder.None:                     case GridSortOrder.Descending:                         expression.SortOrder = GridSortOrder.Ascending;                         e.Item.OwnerTableView.DataSource = GetData("Name", true, skip, take);                         //Response.Write("asc");                         break;                     case GridSortOrder.Ascending:                         expression.SortOrder = GridSortOrder.Descending;                         e.Item.OwnerTableView.DataSource = GetData("Name", false, skip, take);                         //Response.Write("desc");                         break;                 }                 RadGrid1.CurrentPageIndex = 0;                 e.Item.OwnerTableView.SortExpressions.AddSortExpression(expression);                 e.Item.OwnerTableView.Rebind();             }         } ...         private IList<Swh.Wb8.Entities.Category> GetData(string sortColumn, bool sortOrder, int skip, int take)         {             IGenericDao<Swh.Wb8.Entities.Category> Dao = new GenericDao<Swh.Wb8.Entities.Category>();             IList<Swh.Wb8.Entities.Category> list = Dao.GetObjects(new Order(sortColumn, sortOrder), skip, take, out recordCount);             RadGrid1.VirtualItemCount = recordCount;             return list;         }

What happens is:
When I click a header I'll get the clicked column name and order(asc/desc) and sends the values to the database (GetData)
GetData returns the new rows and binds it to the grid.
Telerik also have the superb feature of what they call: VirtualItemCount.
As you see from my IList<T> from NHibernate I have an output parameter (recordcount) with the total rows in database.
I send in the recordcount into the grid so it can caluculate the paging mechanism. Fantastic! :)
If you can fix this you will be my hero! :)
Best Regards
Mattias

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.