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

[Solved] Grid Data to Javascript Variable

2 Answers 232 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 14 Sep 2009, 01:05 AM
Is it possible to get all dataitems in a grid and put in a javascript var.
Then, take that variable and set it to the datasource of another grid?
I found the get_dataItems() method, however, I dont know if this is
possible.

OR

Is there a way I can get the grid data into a C# datatable on the server
if I am using client side databinding?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 16 Sep 2009, 11:29 AM
Hello Josh,

Unfortunately, none of the two cases are supported off-the-shelf in RadGrid. Your client-side GridTableView object provides the get_dataItems() method that returns a collection of all data items (as client-side objects). You need to loop over your data item, traverse their cells and extract the values from there.

You can find attached a small page I have created that demonstrates this. The generated array of data objects can be serialized to JSON, or directly assigned as a data source to another RadGrid on the client.

As for the second scenario, RadGrid databound on the client does not carry any data back to the server. Therefore, you will not be able to access and RadGrid data to build a server-side DataTable.

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Josh
Top achievements
Rank 1
answered on 16 Sep 2009, 02:10 PM
The example posted gave me exactly what I needed.  Thanks.

Joshua
Tags
Grid
Asked by
Josh
Top achievements
Rank 1
Answers by
Veli
Telerik team
Josh
Top achievements
Rank 1
Share this question
or