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

Dynamically added RadDock with Dynamically populated RadGrid - Best Practice Question

3 Answers 128 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 2
Eric asked on 20 Apr 2009, 07:01 PM
Hello,

First, I just want to say that I'm really enjoying all of the functionality, simplicity and capabilities built into the RadControls for ASP AJAX.  There's a lot to digest, but for the most part I've been able to figure out how to accomplish everything I set out to accomplish.  That said, I have a scenario where I've been unable to discover a solution.  I'm hoping that there is a simple, elegant solution to my problem.

I have built an application that dynamically creates RadDocks and loads them into a Layout using an UpdatePanel (based on your dynamic RadDock demo, of course).  These RadDocks contain one RadGrid each.  I want the RadDocks to load up immediately with a "loading, please wait" animation playing while the RadGrid in the dock is updated (a la PageFlakes).  Based on this usage requirement, it seems that each grid needs to get data via a client-side Web Service call based on parameters provided by the user.  Here's where I run into problems:

  1. I found an example in the forums (I can't find the thread again, but the sample project file was called '125798_webservice.zip') that almost works as I'd like.  It does everything I described above, and even returns a view of the data pre-bound to a control and sent as HTML rather than a collection of rows, which I think is a better approach, but it builds the view using an asp:Repeater control instead of a RadGrid.  All attempts to use a RadGrid (or even an asp:GridView) in this way have failed.  The exception thrown instructs me to put the grid control in a form tag with runat="server" as an attribute.  I've done this, but that throws all kinds of other problems...
  2. Since that didn't work, I figured I'd try and attach to a RadGrid's 'Initialize' or 'Created' event and load the data via client-side databinding.  I can add empty RadGrids to the RadDocks when I create them, but I'm having a very difficult time getting each grid to go fetch data and update the view.  I can't seem to successfully attach to a RadGrid create event and cause the grid to fetch and update.  Even if I could capture the event properly, I can't seem to get a handle to the MasterTableView of the RadGrid.  Another bummer is that I want autogenerated columns for most of these RadGrids, and I learned today that client-side databinding requries explicitly defined columns... so client-side databinding isn't the answer.
  3. I tried using client script to fetch the data and programatically add rows to the grid, but this requires a TON of JavaScript (not ideal) - especially considering that I have no idea what the columns will look like for each RadGrid.  I did get this to work for one type of table, but I don't know how I can generalize this code enough to cover all the potential table layouts I will encounter.  I suppose I COULD figure out all the possible column combinations and write script to handle them, but wow... I really don't want to do that.

Of all the solutions I listed, number 1 was the closest to working as I'd hoped.  It was even pretty elegant in its approach.  If I could get a RadGrid to render properly in that scenario, that would be great.  That said, I'm more interested in knowing the "right" way to do this vs. the easiest.  I do want it to be reusable and easy to maintain, but if I can get that without writing my massive JavaScript library... that would be great!

I'll appreciate any help,
Eric Dzikowski

3 Answers, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 2
answered on 21 Apr 2009, 02:30 PM
So... no one has any ideas?

-
Eric Dzikowski
0
Eric
Top achievements
Rank 2
answered on 22 Apr 2009, 01:48 PM
Wow... no replies at all.  Should I post this question in the RadGrid forum?

-
Eric Dzikowski
0
Nikolay Rusev
Telerik team
answered on 23 Apr 2009, 02:59 PM
Hello Eric,

"..returns a view of the data pre-bound to a control and sent as HTML rather than a collection of rows.." - I assume that you have tried to bind RadGrid(and/or GridView) control on server and then return only rendered html for the bounded rows. Unfortunately this is something that I do not suggest you to do with ajax enabled controls.

You can try once Dock is loaded to execute request to the server in order to create and bind RadGrid and in the mean time show RadAjaxLoading panel. For the purpose you check the following links:
Show RadAjaxLoadingPanel on initial page load
Grid / Programmatic Binding

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Eric
Top achievements
Rank 2
Answers by
Eric
Top achievements
Rank 2
Nikolay Rusev
Telerik team
Share this question
or