Skip to Content

custom column formatting not working FIORI Work List Page

Hi all,

i have a requirement in FIORI Work List report to format a field in Report. the data received from table is in object format that needs to be formatted according to desired format.

Below is the table shown when we directly bind the path using local annotations.

To achieve this i have created a custom column using fragments and applied formatting function in extending controller as below.

"sap.ui.viewExtensions": {
"sap.suite.ui.generic.template.ListReport.view.ListReport": {
"ResponsiveTableColumnsExtension|ZDetail": {
"className": "sap.ui.core.Fragment",
"fragmentName": "com.test.fiori.ztest.ext.fragments.ListReportResponsiveTableColumns",
"type": "XML"
},
"ResponsiveTableCellsExtension|ZDetail": {
"className": "sap.ui.core.Fragment",
"fragmentName": "com.test.fiori.ztest.ext.fragments.ListReportResponsiveTableCells",
"type": "XML"
}
}

ListReportResponsiveTableCells.fragment.xml

<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns="sap.m" controllerName="com.test.fiori.ztest.ext.controller">
<Text text="{path: 'Criteria', formatter: '.formatCriteria'}"/>
</core:FragmentDefinition>

the formatCriteria method is implemented in extension controller as below

formatCriteria: function (criteria) {
criteria = JSON.parse(criteria);
var sformattedcriteria = "";
for (var key in criteria) {
if (criteria.hasOwnProperty(key)) {
var val = criteria[key];
sformattedcriteria = sformattedcriteria + key + " " + ":" + " ";
sformattedcriteria = sformattedcriteria + val + " " + "AND" + " ";
}
}
return sformattedcriteria.substring(0, sformattedcriteria.lastIndexOf("AND"));
}

ListReportResponsiveTableColumns.fragment.xml

<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns="sap.m">
<Column>
<Text text="Criteria"/>
<customData>
<core:CustomData key="p13nData" value='\{"columnKey": "stext", "columnIndex" : "5"}'/>
</customData>
</Column>
</core:FragmentDefinition>

so basically the "Criteria" field needs to be formatted. but the above formatting is working as desired only when we include the unformatted "Criteria" field in local annotations file

as below

<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="/Name"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="/Type_Text"/>
<PropertyValue Property="Label" String="xyz"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="/testList"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="Criteria"/>
</Record>
</Collection>

if we include both unformatted and custom formatted field in WorkList Report ,the Report works fine but the formatting function fails if we remove the unformatted field in local Annotations.

I Recieve null value in Criteria in formatter function

formatCriteria: function (criteria) {
criteria = JSON.parse(criteria);
var sformattedcriteria = "";
for (var key in criteria) {
if (criteria.hasOwnProperty(key)) {
var val = criteria[key];
sformattedcriteria = sformattedcriteria + key + " " + ":" + " ";
sformattedcriteria = sformattedcriteria + val + " " + "AND" + " ";
}
}
return sformattedcriteria.substring(0, sformattedcriteria.lastIndexOf("AND"));
}

the table only loads when both unformatted and formatted custom coloumn are placed in project .

Is it mandatory to load unformatted field in annotations to get a formatted field . in case if required how to hide the unformatted field in table

Regards

Prasad

278241-capture.jpg (25.9 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.