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

No documentation on adding rows at runtime

4 Answers 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andries
Top achievements
Rank 1
Andries asked on 19 Mar 2009, 06:46 PM
Can you give us a sample / indication on adding rows manually without binding to a strong typed business object? I've seen posts and / or samples specific to columns, but not data rows.

Is this possible? This has been asked by other people as well, but no answers?

Andries

4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 20 Mar 2009, 04:18 PM

Hi Andries,

You can not add GridViewRows runtime to the RadGridView without it being bound to some kind of collection.

However a workaround would be to bind the grid to an empty collection and populate it runtime.

If the collection is capable of notifications , the grid will automatically update the UI with the new items. ( e.g. ObservableCollection).

Now the tricky part:  The object is not strongly typed, so you do not know its structure until runtime. Therefore you should build  the RadGridView columns runtime by adding new GridViewDataColumn object to the RadGridView.Columns collection for each property of your custom object.

Then to represent the custom object in a row we may use List<object> e.g. each row will be a list of objects representing the properties of your custom object.  Each property of your custom object maps to an item of that list.

We put this rows in another list  to form usable datasource for the grid so the final result would be:
List<List<object>>

So what you need is to convert the data you want to display to a "list of list of objects".

As I have mentioned in  another thread  where we discussed the same problem, I will be glad to prepare a sample for you. What I need is just your implementation of the data. Then I can prepare for you the code to populate the grid from your custom data runtime. I appreciate your understanding that since your scenario is quite specific we can not provide a general example for it.

Sincerely yours,

Pavel Pavlov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Atiq Ur Rehman
Top achievements
Rank 1
answered on 24 Mar 2009, 10:58 AM
The link is not working, can you please update the link?
0
Pavel Pavlov
Telerik team
answered on 25 Mar 2009, 12:36 PM
Hi
I have posted a sample solution here.


Kind regards,
Pavel Pavlov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Andries
Top achievements
Rank 1
answered on 25 Mar 2009, 03:54 PM
Perfect!
Tags
GridView
Asked by
Andries
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Atiq Ur Rehman
Top achievements
Rank 1
Andries
Top achievements
Rank 1
Share this question
or