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

Grid rebinds with Popup Edit Form

2 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 19 Nov 2010, 07:33 PM
My grid setup seems to have caused some unwanted behavior that I'd like to prevent if possible.

I have an ajaxified grid that I'm filtering through an outside radcombobox. The radcombobox sets a public variable that I then use in the NeedDataSource event to filter the grid. All of this works great except that when I click to edit a row using a popup edit form, the grid rebinds itself and I lose that filter.

Can you tell me how to preserve my grid filtering when the popup edit form appears and closes? Do I need to move my grid filtering to a different grid event for that?

btw...I'm using LINQ for my data source

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
     DataClassesDataContext db = new DataClassesDataContext();
     var query = from episodes in db.Episode_Dims
              orderby episodes.ep_skey descending
              select new { episodes.season_skey, episodes.ep_skey, date_skey =
              Convert.ToDateTime(episodes.date_skey.ToString()) };
 
     if (maxSeason > 0)
          query = query.Where(p => p.season_skey == maxSeason);
 
     RadGrid1.DataSource = query;
}

2 Answers, 1 is accepted

Sort by
0
Philip Senechal
Top achievements
Rank 1
answered on 19 Nov 2010, 08:06 PM
I think I got it figured out actually. I was looking at the webmail demo and saw that the dropdowns in that demo are making use of RadGrid.OwnerTableView.FilterExpression. Instead of having my dropdown filter the query in LINQ, I changed it to filter the grid directly and it works. I suppose this is okay since the query isn't bringing back a whole lot of records, but it would still be nice to do this at the database level so I'm not bringing back so many rows.
0
Radoslav
Telerik team
answered on 25 Nov 2010, 09:33 AM
Hi Philip,

I am glad that you achieved the desired functionality. When you bind the RadGrid via advanced DataBinding and applying custom filtering, operating with the RadGrid.OwnerTableView.FilterExpression is the right way.
Additionally if you use a DataSource control, which supports filtering (LinqDataSource, OpenAccessDataSource, EntityDataSource), the RadGrid will load only the filtered data.

I hope this helps.

Best wishes,
Radoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Philip Senechal
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or