This is a migrated thread and some comments may be shown as answers.

Grid doesn't refresh using sort

3 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 15 Jan 2009, 09:22 PM
I have the following function to populate a grid. The select info returns a DataTable with the data. Everything works fine until I try to sort. I click the first time and the sort works fine. If I click the column again, nothing happens. I have the NeedDataSource event enabled, with the following code (rgData.MasterTableView.DataSource= SelectInfo();)  Looks like the grid is keeping a cache of the data, because the function returns the data sorted correctly, but the grid keeps the display wrong

Bind data function
function InitGrid()
{
rgData.MasterTableView.DataSource= SelectInfo();
 rgData.DataBind();
}

Sort Event
if (!e.Item.OwnerTableView.SortExpressions.ContainsExpression(e.SortExpression))
  {
/*controls used for function to define sorting order*/
   txtHSortOrder.Value = "A";
   txtHSortBy.Value = e.SortExpression;
   e.Item.OwnerTableView.SortExpressions.AddSortExpression(e.SortExpression);
  }
  else
  {
   txtHSortOrder.Value = "D";
  }

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jan 2009, 05:17 AM
Hi Will,

From the above code I think you calling DataBind() from the NeedDataSource event. Try removing that line of code and see if it is working.
Note: You should never call the DataBind() method from inside the NeedDataSource handler or mix simple data-binding mode with advanced data-binding
Advanced data-binding

Thanks
Shinu.

0
Will
Top achievements
Rank 1
answered on 16 Jan 2009, 02:41 PM
I'm using just this line inside that event and the problem is still there:
rgData.MasterTableView.DataSource= SelectInfo();
0
Georgi Krustev
Telerik team
answered on 19 Jan 2009, 03:02 PM
Hi Will,

Can you provide some more information in order to be able to assist you further? I will ask you to post in this thread your NeedDataSource handler because we might be missing something.

If you don't want to apply a specific sort expression to the SortExpressions collection, there is no need to add the e.SortExpression to the collection.

If the problem persists, feel free to open support thread and attach a working test project to it. Thus I will do my best to help you in resolving this issue.

Kind regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Will
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Will
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or