public
partial
class
Myobjects : Page
{
public
Myobjects()
{
InitializeComponent();
radPropertyGrid1.Item =
new
Customer();
}
public
class
Customer
{
[Browsable(
false
)]
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
}
}
9 Answers, 1 is accepted
In the current version of RadControls, RadPropertyGrid does not respect the Browsable attribute. However, we plan adding support for some attributes (including Browsable) in the future versions. The current recommended approach in scenarios with autogenerated property definitions is to subscribe to RadPropertyGrid's AutoGeneratingPropertyDefinition event, in order to cancel the generation of any unwanted entries.
All the best,
Ivan Ivanov
the Telerik team
using the latest internal build (2013.2.805.45) I still face a problem with Browsable.
I extend a Linq2Sql class like this.
[MetadataType(
typeof
(Material.DAMetaData))]
public
partial
class
Material {
private
void
Test() {
}
public
class
DAMetaData {
//works
[Display(Name =
"The Name"
, Order = 1)]
public
object
Name {
get
;
set
; }
//works
[Display(Name =
"The description"
, Order = 2)]
[ReadOnly(
true
)]
public
object
Description2 {
get
;
set
; }
//works
[ReadOnly(
true
)]
public
object
Replaces {
get
;
set
; }
//works and does what Browsable(false) should do
[Display(AutoGenerateField =
false
)]
public
object
Description3 {
get
;
set
; }
//NOT working
[Browsable(
false
)]
public
object
SearchDescription {
get
;
set
; }
}
}
In the comment I showed what is working an what not.
Since Display(Autogenerat.... works this is not a big problem. I just wanted to inform you.
Manfred
I have tested the case and Brosable(false) is applied correctly. Will it be possible to check out the sample attached and verify whether I am missing anything ?
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
YES you missed something in your project.
First please add a reference to System.ComponentModel.DataAnnotations.
Next please change the club as follows; (you can copy it there replacing the existing lines).
...
using
System.ComponentModel.DataAnnotations;
namespace
RadGridView_WPF_AR_16
{
/// <summary>
/// A football club.
/// </summary>
[MetadataType(
typeof
(Club.DAMetaData))]
public
class
Club : INotifyPropertyChanged
{
public
class
DAMetaData {
[Browsable(
false
)]
public
string
Name {
get
;
set
; }
[Display(AutoGenerateField =
false
)]
public
int
StadiumCapacity {
get
;
set
; }
}
public
event
PropertyChangedEventHandler PropertyChanged;
private
string
name;
private
DateTime established;
private
int
stadiumCapacity;
public
string
Name
{
...
I removed Browsable from the Name Property.
Instead I used a nested Metadata class and applied the Annotations there.
As I wrote in my first post I have to use this kind of Metadata assignemet since my classes are generated by SQLMetal (linq2sql).
By the way - your example works in it's original form.
Manfred
Indeed, you are right - I managed to reproduce the issue and to resolved it. The fix will be available in our internal build coming next Monday. Thank you for reproducing it, I have updated your telerik points accordingly.
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
[Browsable(false)] attribute in MetaDataType class is still not working, i am using your latest build.
[MetadataType(
typeof
(Club.DAMetaData))]
public
class
Club : INotifyPropertyChanged
{
public
class
DAMetaData {
[Browsable(
false
)]
public
string
Name {
get
;
set
; }
[Display(AutoGenerateField =
false
)]
public
int
StadiumCapacity {
get
;
set
; }
}
}
[MetadataType(
typeof
(Club.DAMetaData))]
public
class
Club : INotifyPropertyChanged {
public
class
DAMetaData {
[Browsable(
false
)]
public
string
Name {
get
;
set
; }
[Display(AutoGenerateField =
false
)]
public
int
StadiumCapacity {
get
;
set
; }
}
}
I modified the sample previously attached with the latest binaries and the Browsable attribute is respected appropriately. Check out the newly updated project and let me know in case there is some misunderstanding on the issue.
Regards,
Maya
Telerik
Hello Maya,
I checked your modified sample, and it is working.
BUT, in my case it is not working, because I am using multiple objects in property grid.
you can observe this issue when you will modify your sample as
<telerik:RadPropertyGrid Item="{Binding Clubs}" PropertySetMode="Intersection" />
in above change i added PropertySetMode="Intersection" and changed Clubs[0] to Clubs.
could you plz tell me why MetaData annotation is not working when we use multiple objects with PropertySetMode=Union or Intersection.
Indeed, you are right. I tested the case when working with property sets. I logged the issue in our system for further investigation. You can follow its progress from the Feedback Portal.
Regards,
Maya
Telerik