on 12-08-2017 4:20 AM
Hey,
This is not going to be pretty.
You can work on the CSS side but you'll have a lot of issues if you'd need to set the design dynamically.
I'm attaching a code snippet that registers an event in the "onInit" named "updateFinished" that is handled later in the function "onUpdateFinished".
In it, I randomly took the second item (you can put your own logic on deciding which one to style its border) and via the DOM reference I changed it's style to have borders (see var domRef).
There are many issues with this example, especially if your app is in some supper app, but you would have to deal with that.
The code I manipulated is based on the Fiori work-list app.
The relevant code in Worklist.controller.js:
onInit: function() {
var oViewModel,
iOriginalBusyDelay,
oTable = this.byId("table");
// Put down worklist table's original value for busy indicator delay,
// so it can be restored later on. Busy handling on the table is
// taken care of by the table itself.
iOriginalBusyDelay = oTable.getBusyIndicatorDelay();
// keeps the search state
this._aTableSearchState = [];
// Model used to manipulate control states
oViewModel = new JSONModel({
worklistTableTitle: this.getResourceBundle().getText("worklistTableTitle"),
saveAsTileTitle: this.getResourceBundle().getText("saveAsTileTitle", this.getResourceBundle().getText("worklistViewTitle")),
shareOnJamTitle: this.getResourceBundle().getText("worklistTitle"),
shareSendEmailSubject: this.getResourceBundle().getText("shareSendEmailWorklistSubject"),
shareSendEmailMessage: this.getResourceBundle().getText("shareSendEmailWorklistMessage", [location.href]),
tableNoDataText: this.getResourceBundle().getText("tableNoDataText"),
tableBusyDelay: 0
});
this.setModel(oViewModel, "worklistView");
// Make sure, busy indication is showing immediately so there is no
// break after the busy indication for loading the view's meta data is
// ended (see promise 'oWhenMetadataIsLoaded' in AppController)
oTable.attachEventOnce("updateFinished", function() {
// Restore original busy indicator delay for worklist's table
oViewModel.setProperty("/tableBusyDelay", iOriginalBusyDelay);
});
},
/* =========================================================== */
/* event handlers */
/* =========================================================== */
/**
* Triggered by the table's 'updateFinished' event: after new table
* data is available, this handler method updates the table counter.
* This should only happen if the update was successful, which is
* why this handler is attached to 'updateFinished' and not to the
* table's list binding's 'dataReceived' method.
* @param {sap.ui.base.Event} oEvent the update finished event
* @public
*/
onUpdateFinished: function(oEvent) {
// update the worklist's object counter after the table update
var sTitle,
oTable = oEvent.getSource(),
iTotalItems = oEvent.getParameter("total"),
domRef = oTable.getItemsContainerDomRef();
//Set some random item's border
domRef.children[1].children[1].style = "border-top: 2px solid black !important;" +
"border-bottom: 1px solid black !important; border-left: 2px solid black !important; border-right: 2px solid black !important";
// only update the counter if the length is final and
// the table is not empty
if (iTotalItems && oTable.getBinding("items").isLengthFinal()) {
sTitle = this.getResourceBundle().getText("worklistTableTitleCount", [iTotalItems]);
} else {
sTitle = this.getResourceBundle().getText("worklistTableTitle");
}
this.getModel("worklistView").setProperty("/worklistTableTitle", sTitle);
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the final result add-border.png.
Hi Iftah Peretz,
Thanks for your response.
I've tried to merge across column in sap.m.table and notice it's the limitation on this control. So I tried to design in CSS whether it is possible with this. My design would be dynamic and the table will not have fix column.
Actually my expected final output would be like below layout. I'll need to draw the border for each item and merge those value across column which having the same value.
Any suggestion on how to populate below layout?
Hi,
I've given you a cell based solution and I now understand that this might not suffice. Am I right?
If this is the case, there's always an option to revert back into HTML component that you can control completely design wise and use it as a presentation container for your data the way you want to.
Another option is to search for a better fit for you needs in the SDK. Meaning, not to keep that data sap.m.table.
Hi Iftah Peretz,
Thanks for your suggestion. I managed to display the expected layout Sample output
However, I still have some queries on this HTML api.
1.) Since the layout will be dynamic, how could I design for my database in order for me to extract as a json format so that I'm able to generate as a HTML string?
2.) By using HTML component, am I able to click each of the cell and perform further action for example view details of that selected cell by calling a dialog screen?
Appreciate much for your guidance.
Hi,
I'm happy you are seeing progress in your project.
as for your questions:
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.