I have a SAPUI5 table with both String value data (e.g. names) and integer data (e.g. IDs). When I use the in-table search options for strings, it works perfectly.
When I try to search for part of an ID, it throws the following error:
(Uncaught Error: Only "String" values are supported for the FilterOperator: "Contains".)
I want to search through my integers as though they were strings
Attempt 1:
var oTextView = new sap.ui.commons.TextView( {
text : {
path : "id",
formatter : function(oContext) {
if (oContext) {
return oContext.toString();
} else
return;
}
}
});
Attempt 2:
var oTextView = new sap.ui.commons.TextView( {
text : {
path : "id",
type : new sap.ui.model.type.String(),
}
});
Attempt 3:
combining previous attempts with this (result is I cannot open in-table search for this column at all anymore):
oColumn.setFilterProperty(sap.ui.model.type.String())
oColumn.setSortProperty(new sap.ui.model.type.String())
Edit: view/controller
view:
var oTable = new sap.ui.table.Table();
oTable.setModel(sap.ui.getCore().getModel("myModel"));
oTable.bindRows("/myPath");
var oTextView = new sap.ui.commons.TextView();
oTextView.bindProperty("text", "myProperty");
var oColumn = var oColumn = new sap.ui.table.Column({
label : new sap.ui.commons.Label( {
text : "My Column"
}),
template : oTextView,
sortProperty : "myProperty",
filterProperty : "myProperty",
});
oTable.addColumn(oColumn);
Controller:
var oModel = new sap.ui.model.json.JSONModel(MyData);
sap.ui.getCore().setModel(oModel, "myModel");