GridView handling of properties with Browsable(false) attribute

2 Answers 17 Views
GridView
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Marian asked on 21 Apr 2024, 11:03 PM

Hello,

I have question about GridView handling of properties with Browsable(false) attribute. It's expected that when I add this attribute to some property, automatic generation of columns will ignore it. But why when I add this column manually, that column is empty. Is it a bug? I think that attribute means that should not be displayed in PropertyGrid, but it doesn't prevent to read / write property. It's not problem for me, that's just question, I ran into it during some other tests.

But, maybe it's not bug but expected behavior, but when I add this attribute to property used as ID for self referencing hierarchy, program freezes on startup, and I think this is a bug, isn't it?

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 24 Apr 2024, 10:44 AM

Hi Marian,

Thank you for reaching out to us.

When the Browsable(false) attribute is used, the control won't get this property from the business objects. Basically, it will ignore this property as an available one. That is why if you manually add a column pointing to this property, it will be empty. The control could not find such property as it is not available due to the attribute.

Setting the Browsable(false) will not hide the property from generating a column. When the control tries to get the available property of the object in the DataSource, it will ignore the one with that attribute and it will generate a column for all other properties.

In a self-referencing hierarchy, that attribute is set to a property used to generate the hierarchy it will break the generation logic as such property does not exist. If you want to hide a specific column in this case, you can get that column from the Columns collection and set its IsVisible property to false and avoid using the Browsable(false) attribute.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Marian
Top achievements
Rank 2
Iron
Iron
Iron
commented on 24 Apr 2024, 05:02 PM | edited

Hello,

ok, but it's Telerik solution of handling Browsable attribute, because of course you can get property value by reflection also for not browsable properties. So GridView must also check this attribute and ignore property by itself.

Yes, I know I can hide it by IsVisible, also in column chooser by VisibleInColumnChooser. I came to this point by testing something else and set Browsable(false) accidentally just to ID property for self referencing. I understand it will break logic of self referencing, but I was pointing to the fact that GridView was frozen. And I consider this a bug, I think control should never freeze or crash under any condition. It's not problem for me, of course I will not use not browsable ID, I just asked question because of this freezing, to notify you of this bug. I think control should ignore self refencing in this case, or throw some exception, but not freeze.

Dinko | Tech Support Engineer
Telerik team
commented on 29 Apr 2024, 09:43 AM

I can agree with you that the control should not freeze. In my test project, the control does not freeze. In this case, the data will not be loaded in the control. I could be missing something here from your implementation. Can you check the attached project, modify it to reproduce the reported behavior and send it back so that I can debug it and try to find a suitable solution for you?

I am looking forward to your reply.

Marian
Top achievements
Rank 2
Iron
Iron
Iron
commented on 29 Apr 2024, 10:10 AM | edited

Hello,

I took a quick look at it, and it's not freezing in your project. I can send you my test project (TestTelerikSelf in solution), maybe it's related also to something else. I have found out that my project freeze, when I set both ID and ParentID as not browsable, if only one is not browsable, it just ignore self referencing.

To the part "try to find a suitable solution for you" - it's not a real situation, I think nobody will need to set ID's as not browsable, it's just something I have found out accidentally and report it, if there is some bug, maybe you can fix it.

I noticed one detail in your project, you have parent id a nullable. I don't have nullable parent id in my project, as it was in samples, and using 0 as "no parent". This would be better solution for top level items.

0
Dinko | Tech Support Engineer
Telerik team
answered on 01 May 2024, 01:46 PM

Hello Marian,

The provided project is greatly appreciated.

I was able to observe the described behavior. It is reproducible when the columns are predefined and added to the RadGridView columns collection. If I let the control auto-generate the columns when the attribute is set to both properties, the freeze is not observed. That is the difference between my project and yours. 

Indeed, setting this attribute to the properties is a kind of invalid scenario. However, the control should not freeze. Instead, no data should be shown in the control. I can confirm that this could be improved on our side. Therefore I have logged it in our Feedback Portal on your behalf, where you can track its progress and follow the item. This way you can receive status notification changes.

By solution, I mean to find what is causing this and somehow handle it programmatically so that the application does not freeze. I agree that this is not a real scenario, but still, as I mentioned above, the control should not freeze.

Using a null value as the main parent was just an example. Probably starting from 0 will be better to structure the hierarchy. I appreciate the feedback and will take this into account.

Your Telerik Points are updated for bringing this scenario to our attention.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Tags
GridView
Asked by
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or