[ISSUE][ListGridField]setHidden()

Hi all,

I am facing the following issue :

I create a grid that I link to a DataSource
I instantiate the ListGridField of my grid.
I want some columns to be hidden so I just do a setHidden(true) on those.
But it’s not working : columns are still displayed.
I also put setHidden(true) on the corresponding DataSourceField but it doesn’t help.

Am I missing something there ?

Regards

Both seem to be working in examples. Can you show your code?

ListGridField.setHidden is not a valid call and it should be removed from the class. DataSourceField.setHidden should be used instead and there are working examples of this in the Showcase. See CountryXmlDS.

DataSourceIntegerField pkField = new DataSourceIntegerField("pk");
pkField.setHidden(true);

Sanjiv

Hi,

thank you for your answers.
Nevertheless :

the example in the show case work because the form and the grid are not specified. They are just automatically generated by linking them to the datasource.

What I want to do is to link my form and my grid to a datasaource but I also need to add event management on my form items and cell renderer to my grid columns. So I have decided to manually create my GridListField and my form Items (and to call setDataSource on both too).

Now, in my DataSource for example I have an Id field (the primary key). I put it hidden by using the setHidden on the DataSourceField.
For internal treatment purpose I need to have the Id in the grid but not visible by the users. I create the GridListField for this Id

Result : the column is not hidden. And if I also call the GridListField method setHidden(true) it is still displayed.

I hope u got my point : I think there is a bug in there, or I’m missing something.

One last point : I don’t understand why the visibility of an item has to be managed on the datasource object. It is a L&F aspect so for me it would be better to put it on the View side, not on the model side (if, for example, someone want to hide a field in the grid but to display the corresponding item in his form, he will need to do a setHidden on the grid field but not on the form Item, so it has to be separated and not to be put on datasource side)

Regards

I agree. I’ll be making a change in SVN so that the ListGridField.setHidden(..) works on the view as desired.

Sanjiv

Two further notes:

  1. the behavior you describe of showing a field in a form but not a grid by default is built-in and is enabled by DataSourceField.setDetail()

  2. SmartGWT already supports controlling visibility at both the DataSource and component level, via ListGridField.setShowIf() and FormItem.setShowIf(). These APIs take JavaScript expressions and so will be reworked to be more useful in SmartGWT, however setShowIf(“false”) will hide a field unconditionally.

great !
thank you for those hints, they will be very useful for what I want to do :wink:

Respect