Skip to content

Commit

Permalink
GridView, TreeGridView: when auto-generating columns, detect when ite…
Browse files Browse the repository at this point in the history
…ms are strings and create a singl column with no header text (since there is no field)
  • Loading branch information
joshtynjala committed Nov 12, 2024
1 parent da6bca6 commit 8443c75
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/feathers/controls/GridView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1804,12 +1804,16 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
var newColumns:ArrayCollection<GridViewColumn> = null;
if (this._dataProvider != null && this._dataProvider.length > 0) {
var item = this._dataProvider.get(0);
newColumns = new ArrayCollection(Reflect.fields(item).map((fieldName) -> {
return new GridViewColumn(fieldName, (item) -> {
var propertyValue = Reflect.getProperty(item, fieldName);
return Std.string(propertyValue);
});
}));
if ((item is String)) {
newColumns = new ArrayCollection([new GridViewColumn()]);
} else {
newColumns = new ArrayCollection(Reflect.fields(item).map((fieldName) -> {
return new GridViewColumn(fieldName, (item) -> {
var propertyValue = Reflect.getProperty(item, fieldName);
return Std.string(propertyValue);
});
}));
}
} else {
newColumns = new ArrayCollection();
}
Expand Down
16 changes: 10 additions & 6 deletions src/feathers/controls/TreeGridView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1441,12 +1441,16 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
var newColumns:ArrayCollection<TreeGridViewColumn> = null;
if (this._dataProvider != null && this._dataProvider.getLength() > 0) {
var item = this._dataProvider.get([0]);
newColumns = new ArrayCollection(Reflect.fields(item).map((fieldName) -> {
return new TreeGridViewColumn(fieldName, (item) -> {
var propertyValue = Reflect.getProperty(item, fieldName);
return Std.string(propertyValue);
});
}));
if ((item is String)) {
newColumns = new ArrayCollection([new TreeGridViewColumn()]);
} else {
newColumns = new ArrayCollection(Reflect.fields(item).map((fieldName) -> {
return new TreeGridViewColumn(fieldName, (item) -> {
var propertyValue = Reflect.getProperty(item, fieldName);
return Std.string(propertyValue);
});
}));
}
} else {
newColumns = new ArrayCollection();
}
Expand Down

0 comments on commit 8443c75

Please sign in to comment.