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

Cell-level types and input validations, instead of Column-level, using RadGridView

4 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Niels
Top achievements
Rank 1
Niels asked on 30 Jun 2011, 12:09 PM
For a WPF application we are currently building, we have a need for a screen where a user can fill in a questionnaire. At the moment I have made a very simple Proof Of Concept based on a RadGridView, with two columns (aptly named) 'Question' and 'Answer'. Both are of type 'string' with no validation. Users can input data very quickly this way.

But thinking about their needs has posed me with a problem, let me explain. For example, in a list of questions, users will need to input their Gender, maybe their Date of birth, and their phone number. For the Gender I'd like to limit their choice to a set list of values (M/F/U), for the Date of birth I'd like a DateTimePicker, and their phone number would ideally be checked with a Regular Expression for instance.

It seems to me that, if I were to build a system which can do this dynamically, I'd need to be able to programmatically add cells to the RadDataGrid of a certain type, or have some kind of Cell-level input validation, as opposed to Column-level. Because from what I can see in the documentation, this is merely possible at Column-level (based on the types of attributes of the objects in the list that I would feed the Grid). 

So really my question is, is a certain scenario possible to implement using your RadGridView, or would this imply misuse of your control and would you advice against it? If so, would any of your other controls provide me with the kind of functionality that I'm looking for?

4 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 30 Jun 2011, 02:24 PM
Hello Niels,

Reading your requirements left me with the impression that the control that would best fit into your needs is our brand new RadPropertyGrid. It is included in our recently released Beta package.  Please, let us know if  such an approach meets your requirements and do not hesitate to contact us if any further inquiries occur. We are looking forward to receiving your impressions of our new control.

Greetings,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Niels
Top achievements
Rank 1
answered on 30 Jun 2011, 02:46 PM
Hello Ivan,

The RadPropertyGrid control which you mention, looks promising and more fitting to the requirements than the RadGridView indeed.

Although, looking at the example on this blogpost (http://blogs.telerik.com/blogs/posts/11-06-28/introducing-radpropertygrid-for-silverlight-and-wpf.aspx) leaves me under the impression that this is meant more for a static than a dynamic form. Please correct me if I'm wrong, but let me explain what I'd like to be able to do. I want to declare something like the following dictionary, with the following contents, and bind it to the RadPropertyGrid (pseudocode):

var inputFields = new Dictionary<string, object>();
inputFields.Add("Birthdate"typeof(DateTime));
inputFields.Add("Gender"typeof(Enumerations.Gender));
inputFields.Add("Phonenumber", typeof(string), Validator.PhoneNumberValidator);
RadPropertyGrid.ItemsSource = inputFields;


Is a dynamic way like the example above supported (or likely to be in the future), or is the form meant for forms of which the nature is more static?
0
Ivan Ivanov
Telerik team
answered on 30 Jun 2011, 03:32 PM
Hi Niels,

RadPropertyGrid do support  dynamic content. It can be used to edit any data item's properties,  providing you the opportunity to use different editors for the separate data types. As RadPropertyGrid is designed to process a single item, rather than a collection of items, I would advise you to design a Business Object class, representing the questionnaire sheet that exposes questions as its properties. In such a way you can achieve effortless implementation of your requirements without any complex data binding. Please, let me know if such an approach is applicable in your case.

Greetings,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Niels
Top achievements
Rank 1
answered on 30 Jun 2011, 04:15 PM
Hi Ivan,

I understand what you are saying, but my problem is that the questionnaire sheets are not master data or anything static, but are managable via a GUI.

Therefore, they will have dynamic content (and will be stored in the Database in a dynamic format), and that makes the design of a standard Business object for a questionnaire impossible. I need a dynamic way to build the screen, and can't use a predefined object. The only way this would work is to present a class to the RadGridView/RadPropertyGrid which would use Reflection to construct an object, because only then will your controls provide the correct Input control mechanism.

I hope you understand my point. Another example, using a DataTable for instance would also not be an option. Namely because I would have to define columns which are bound by a type, but I what I need is to specify a datatype per Cell, not Column.

These are the reasons why I'm using a list in my example code. It's a list, but (counter-intuitively) it actually represents a single entity, with types at Cell-level instead of having them at Column-level.

Would you still say that I would benefit from the RadPropertyGrid, given my requirements?
Tags
GridView
Asked by
Niels
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Niels
Top achievements
Rank 1
Share this question
or