If you create a custom DataSource in SmartGWT, is it possible to remove a field filter instead of hiding it entirely from the grid columns?
As seen here:

The Country code field exists, but is hidden in the above image.
Clarification: I want to hide the Country code field at the start, but still have it visible in the Columns context menu. If you use setHidden(true) the field disappears from the Columns menu above.
Example code:
public class MyDataSource extends DataSource {
public MyDataSource() {
DataSourceField countryField = new DataSourceIntegerField("country", "Country code");
// TODO Find a method that disables the filter, aka hides but not removes the field from the grid.
countryField.setHidden(true); // Completely hides/removes the field, not desireable.
countryField.setCanFilter(true); // Doesn't seem to change anything.
addField(countryField);
// Other fields...
}
}
How would this be achieved in a ListGrid with the above DataSource?
I’m not sure if I fully understood the question.
Are you looking for a way to hide the “Country code” option from the Columns context menu? You can do that by declaring
ListGridField.setCanHide(false)to the corresponding ListGridField.Or, are you trying to disable filtering?
If so, does the user have to have the option to see the country code column in some cases?
If not, you can just leave the
MyDataSourceas it is and define only thoseListGridFieldsthat you want the user to see.The underlying country code attribute is still available in the code, eg. via
record.getAttribute("countryCode");, it’s just not shown in the ListGrid.Alternatively, you can define the filtering on grid level with
ListGridField.canFilter(Boolean canFilter).EDIT:
So, don’t set the hidden attribute in the datasource, but instead directly to the
ListGridField.DataSource
ListGrid
That should do the trick.