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

Editing a RadGrid using LinqDataSource and the Where property

3 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seth
Top achievements
Rank 1
Seth asked on 20 Oct 2008, 01:34 AM
I have a radgrid exposing a table with many records in it, in the tens of thousands.

I tried to implement filtering on this grid but I could not get it to work without pulling down enormous ajax responses (around 6 megs). I tried to figure out why the grid was, I'm guessing, trying to do all the filtering on the client side. I followed instructions on doing filtering server side, calling a server method and setting the filterExpression property on the server to handle the filtering but for whatever reason, the grid would not filter without pulling down these multi megabyte ajax responses.

Stumped, I instead wrote my own custom filtering functionality, using the Where field of the LinqDataSource I have connected to the radgrid. This worked wonderfully, nice and lean it would filter the grid. It worked wonderfully, that is, until I discovered editing wasn't working with my LinqDataSource's Where field manipulation. Specifically, hitting the GridEditCommandColumn on the grid wasn't pulling up the correct grid item.

Investigating the OnEditCommand event of my grid, I discovered the Where field of my LinqDataSource was coming up blank after I had set it dynamically in my filter method. The Where parameter I set was there, but not Where string ("Id == @Id" OR whatever). I also realized eventually that neither sorting or paging were working with the filtration either. The Where property wasn't keeping.

Does this sound like a viewstate problem? I have enabled viewstate on the LinqDataSource but I imagine it was probably that way by default, and still the Where property doesn't keep.

I wrote a workaround that saves the Where field string in a page member and in the OnEdit-Sort-PageCommand event checks to see if a Where parameter is on the LinqDataSource, and if it is puts the Where property value back. It's hacky though and it seems as though I'm missing something.

Seth

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 22 Oct 2008, 01:03 PM
Hello Seth,

I am afraid I cannot completely understand the problem you are facing. When attempting to filter, RadGrid will define proper values for the parameters of the data source control and the amount of data that will be returned to RadGrid will be equal to PageSize. If you ajaxify your grid control, you will see that the only markup that is transferred during ajax request is the RadGrid markup.

For your further convenience I prepared a test project showing ajaxified RadGrid bound to LinqDataSource. Intercept the LinqDataSource.OnSelecting and LinqDataSource.OnSelected events and see what amount of data is returned to RadGrid.

Best regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Seth
Top achievements
Rank 1
answered on 28 Oct 2008, 08:55 AM
I implemented the example you posted exactly as is, only changing the appcontext and table name properties on the linqdatasource, and taking out all the columns except for the id column, but I still get the same results: anytime any filtering it done I get a huge http responses (Around 6 megs)

I continued to simplify. I figured if it wasn't the code it had to be the database table. I removed all the relationships from the table, deleted all the fields except a few varchars and the id, but still I get very large http responses.If I delete a few thousand records from the database I see the http responses decrease in size (from 6 megs to say 4).

This happens even if ajax isn't in effect. If I remove the AjaxManager, and try to do any kind of filtering, the page posts back and responds with a multi megabyte return page.

If I use the FilterExpression property of the MasterTableView for the grid, loading the grid filtered from the get go, I get a multi megabyte html page, with a very very long viewstate line.

Any ideas? Your assistance is greatly appreciated,

Seth
0
Nikolay Rusev
Telerik team
answered on 31 Oct 2008, 08:00 AM
Hello Seth,

Unfortunately I am not able to tell what might cause this issue. To troubleshoot the issue , you can use the Fiddleer tool.

You can also check our online demos to see how RadGrid is working.

Sincerely yours,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Seth
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Seth
Top achievements
Rank 1
Share this question
or