Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all 6178 articles
Browse latest View live

Read File using fileuploader

$
0
0

Dear all,

 

I have fileuploader and button that will triggered my file reader script.

 

Image 024.png

 

i want to read the file after click the button 'Upload' without upload the file. Just to read the content

How to do that? I tried with this.getView().byId('fileuploaderId').files[0] but i got an error...

 

Thanks

Best Regards

Yoppie A.


Insert excel file Data and display its content in SAPUI5 view

$
0
0

Hi All,

 

when i insert data in a table from excel sheet so data is not showing in a last column.

 

View

 

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"    

              controllerName="simple_table.table" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:t="sap.ui.table">

       <Page title="Title">

              <content>

 

 

       <Link text="upload" press="onConfirmDialog"/>

      

       <t:Table id ="mytbl" rows="{/}" visibleRowCount="5" width="1281px" >

 

 

                     </t:Table>

 

 

      

              </content>

       </Page>

</core:View>

 

 

Controller

 

sap.ui.controller("simple_table.table", {

 

 

/**

* Called when a controller is instantiated and its View controls (if available) are already created.

* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.

* @memberOf simple_table.table

*/

       onInit: function() {

 

 

             

             

              var oModel = new sap.ui.model.json.JSONModel();

 

 

              this.getView().setModel(oModel);

            sap.ui.getCore().setModel(oModel);

              

              

       },

       onConfirmDialog: function () {

        var that = this;

              var dialog = new sap.m.Dialog({

                     title: 'Upload',

                     type: 'Message',

                     icon: 'sap-icon://download',

                     content: [

                          

                              new sap.ui.unified.FileUploader({

                                  id: 'fileuploader',

                                    width: '100%',

                                    uploadUrl: 'upload/',

                          change: function(oEvent) {

                              var file = oEvent.getParameter("files")[0];

                              if (file && window.FileReader) {

                                var reader = new FileReader();

                                reader.onload = function(evn) {

                                  var strCSV = evn.target.result; //string in CSV

                                  that.csvJSON(strCSV);

                                };

                                reader.readAsText(file);

                              }

                              dialog.close();

                            }

                          })

                        ],

 

 

                    

                     endButton: new sap.m.Button({

                           text: 'cancel',

                           press: function () {

                                  dialog.close();

                           }

                     }),

                    

                     afterClose: function() {

                           dialog.destroy();

                     }

              });

      

              dialog.open();

       },

 

 

       csvJSON :   function(csv){

       

        var lines=csv.split("\n");

      

        var result = [];

      

        var headers=lines[0].split(",");

      

        for(var i=1;i<lines.length;i++){

      

               var obj = {};

               var currentline=lines[i].split(",");

      

               for(var j=0;j<headers.length;j++){

                     obj[headers[j]] = currentline[j];

               }

      

               result.push(obj);

      

        }

       

        var columnArr = [];

        var oStringResult = JSON.stringify(result);

        for( var key in result[0]){

              columnArr.push(key);

        }

       

          var oFinalResult = JSON.parse(oStringResult.replace(/\\r/g, ""));

           sap.ui.getCore().getModel().setProperty("/", oFinalResult);

          

           var tbl = this.getView().byId('mytbl')

          

           var col = tbl.getColumns();

          

           if(col.length > 0){

                 tbl.removeAllColumns();

           }

          

           for(var i=0 ; i< columnArr.length ; i++){

                

               tbl.addColumn(new sap.ui.table.Column({

                    label: new sap.ui.commons.Label({text: columnArr[i]}),

                           template: new sap.ui.commons.TextView().bindProperty("text",columnArr[i])

                     }));

           }

          

          

/*           tbl.bindAggregation("columns","/" , function(sid,oContext){

          return new sap.ui.table.Column({

         text: oContext.getProperty("Tplnr"), //bound to model

         icon: "sap-icon://inbox", //bound to model

         toggleOpenState: function(oEvent) {

           console.log("Node is opened: "+ oEvent.getParameter("opened"));

         }

       });

       });

*/          

          

      },

/**

* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered

* (NOT before the first rendering! onInit() is used for that one!).

* @memberOf simple_table.table

*/

//     onBeforeRendering: function() {

//

//     },

 

 

/**

* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.

* This hook is the same one that SAPUI5 controls get after being rendered.

* @memberOf simple_table.table

*/

//     onAfterRendering: function() {

//

//     },

 

 

/**

* Called when the Controller is destroyed. Use this one to free resources and finalize activities.

* @memberOf simple_table.table

*/

//     onExit: function() {

//

//     }

 

 

});

 

 

Output screen



Capture1.JPG

 

Capture2.JPG

Do you have any solutions ? I appreciate for your help.


Thanks & Regards,

Ayushi

clear the object in model in sapui5

$
0
0

Hi gurus,

                  I am still getting used to SAPUI5 and I am trying to clear the model with model.destroy() and it does not work, Is it not possible to delete the whole data in sapui5 , If that's the case , I would be really surprised.

 

Your early response is appreciated.

 

 

Thanks

Somil

 

Here is the screen shot of the console :

 

odata.JPG

Reusabilty in SAPUI5

$
0
0

Hello Experts,

 

I am trying to develop a view which can be reused by other projects. For this, I have created an xml fragment and a javascript file which contains the event handlers for the UI controls in the fragment .

 

If I have to use this xml fragment (along with the event handlers) in other projects, what should i do? What is the best approach of reusing xml views/controllers. It is of great help if anyone can explain this in details with some code snippet

 

Thanks

Faddy

Gantt Chart in UI5 application

$
0
0

Hello,

 

Is there any way I can build a gantt chart in my UI5 application? I cannot see any library feature for gantt chart.

 

Regards,

Charles

SAP-FIORI APPS (What's wrong with the Database)?

$
0
0

Hello every one,

can anyone tell me in SAP-FIORI why Transactional Apps can run on any database,where as if you want run ANALYTICAL and FACT SHEET Apps  we need HANA DATA BASE?

why other databases didn't support ANAYLYTICAL AND FACTSHEET apps in SAP-FIORI?

what's wrong with SAP-WEB DISPATCHER?

Responsive Table in SAPUI5

$
0
0

Hi Guys,

 

I have one table with 12 columns in my xml view page. I want to make that table responsive that means it looks proper in mobile, ipad, desktop and tv also. What approach should i implement here to accomplish this one?

 

I also want my table header should be fixed and table body content will scroll within a specified area.

 

Is there any sample code available on internet?

 

Regards,

Dhiraj.

Update to table executing only once in SAPUI5

$
0
0

Hello UI5 Developers,

 

I am building an application and here is how it works :

 

1] User punches the login id and password  ( Login button calls a Web Service )

 

2] It takes him to the Search Screen if authenticated.

 

3] User can Enter any search criteria and hit "Search" -> which calls a Web Service everytime the search button is clicked and sets the model to the core .

 

4] The search result is displayed in table view which works for only 1st time.  duh

 

5] If I hit "Back" button and modify my "Search Criteria" then it does not update table even though data is updated in model. (sap.m.table, and xml views).


I tried putting a  method in onBeforeRendering() function to update my table but it only gets called one time ( I checked like 100 times ).


t am using the OnInit() method to bind the model to table .


Now here is the code in the search criteria :


jQuery.ajax({

  type : "GET",

  url : "http://localhost:8080/RR/resources/SupReport", 

 

    data : search,

 

  dataType : 'json',

 

 

  success : function(result) {

 

 

  if (result[0].succes === true) {

 

  var oRouter = sap.ui.core.UIComponent.getRouterFor(that);


  var oModel = new sap.ui.model.json.JSONModel();

 

  oModel.setData(result);

 

  sap.ui.getCore().setModel(oModel, "data");

 

  var view = sap.ui.getCore().byId("SupervisorList");

 

 

  if (view === undefined) { --->>>>>>>>>>   code added to call the  update table method in the table view


  view = sap.ui.xmlview("SupervisorList",

  "RR.rr.view.SupervisorList");

  oRouter.navTo("thirdView");

 

 

  } else {

 

 

  view.getController().myMethod();  --->>>>>>>>>> called in table view

  oRouter.navTo("thirdView");

  }

  }

 

  },

============================================


Inside table view :

==========================


myMethod : function() {


var aData = sap.ui.getCore().getModel("data").getData();

var model = this.getView().byId('SupRecertTable').getModel();

 

  var data = model.getProperty("/modelData/recert");

  data.push(aData);

 

  model.setProperty("/modelData/recert", data);

  console.log(model);

  this.getView().byId("SupRecertTable").setModel(model);

 

=========================================================


So My questions is How do I get this working , I have been trying this since past 3 days with no success.

 

 

Please help I am in deep crisis here !

 

Thanks

Somil

 

Message was edited by: Michael Appleby (title needs to reflect the actual issue and do not use the term urgent.  It just irritates other members)


Cordova Build Android Project

$
0
0

Hello Experts,

 

I am upgrading HAT 1.13.3 to 1.14.3. Installed all required software for it. HAT 1.13.3 worked fine. During installation for HAT 1.14.3 ,At step no.6 Cordova Build Android Project Step no7. Cordova Build Windows Project it giving proxy error. I am not behind any proxy.Sharing screenshots

cordova_build_android.JPG

cordova_build_windows.JPG

 


              cordova_android1.JPG

I also checked the IP mentioned in command prompt above, it was cordova plugin website.

I tried it on different systems with prerequisite of software properly installed.

 

Please help , to resolve this

Thanks & regards ,

Kartik

Breakout Smart Template....Add custom view (.xml and .js ) in Smart Template.. SAP WEB IDE

$
0
0

Hi All,

 

for creating standard SMART TEMPLATE  from SAP WEB IDE follow this blog.

 

Create Smart Template Project.........SAP WEB IDE

 

To enable some grid table and object view

 

Manage Smart Template (List View and Object View ) using Annotations file...

 

For adding some custom controls using Annotation.

 

Adding Controls on Smart template  using Annotations...SAP WEB IDE

 

 

Breakout Application in Smart Template by adding some custom view for adding some  custom controls using XML and JS code.


Step 1: create Smart Template from SAP WEB IDE

 

 

 

1.jpg

 

 

Step 2: Select Services

1.jpg

 

Step 3: Select Entity Set and click on finish.

1.jpg

 

Step 4: open your project folder in WEB IDE.

1.jpg

Step 5: Create a folder on ext and in side folder create again folder and add file same as highlighted in snapshot.

1.jpg

Step 6: open manifest.json and add extension code for routing .

1.jpg

Step 7: ext/controller/CustomFilter.fragment.xml .


               I am Adding FilterBar in List View.

1.png


Step 8: ext/controller/CustomFilter.Controller.js

1.png



Step 9: Save it and run project:

Untitled.png

SO its was the HOW TO ADD Breakout SMART Template PROJECT .


Thank you


Virendra Soni


Get All Form Fields value

$
0
0

Hello i have make form using  sap.ui.layout.form.SimpleForm and form contain near about 30-35 textbox and i need to get all textbox value when i submit form.


i have idea get textbox value using it's ID like

$('#textboxid').val();

 

but it's hard process.is there any function i get all textbox , dropdown and etc form fields values.

 

Please help me.

Need to know Response time of ODATA in frontend apps

$
0
0

Hi Experts,

 

I am being involved in my first mobile apps project, system architecture is SAPUI5 framework being used as front end developments, SAP NWG (central hub) for providing the ODATA service which in turn access the RFC of the SAP R/3 backend system.

 

Application consist of login page, then home page contains the left panel with multiple links (3 links).

on the click of each link, in right hand side panel search box and Table control is to be displayed with the Header data, and on selection of any record from the header data table control, next screen should display the detailed data which may in turn contains the few links for further details on new screen.

 

 

While designing the flow for this app, I have got the below query.

 

After the successful login, should I load bring all the master/details data from backend system for all the links (total 3 links in left side panel) in one shot. so that later when user wants to see the details then simply I have to play with data residing on client side, this is I am thinking to gain the faster speed on mobile apps.

 

second approach would be, after the successful logon, lets bring only the minimum required data on client side and then further as and when user clicks on record or link then at runtime through another ODATA service I should pull the data from backend, here in this approach I am worrying for the response time when user clicks on any link and data comes from the backend.

 

for your reference, RFC in backend system returns the maximum 50-100 records as a maximum limit  (each record contains the 20 fields at maximum),

 

business user wants apps should run faster and there should be minimum wait time.

 

please suggest.

 

Regards,

Jagesh

Is it necessary to have filter fields in the entity type?

$
0
0

Hi,

 

I have an entity type.... with the following fields

Employee ID

Employee Name

 

In the url, I want to pass along with the entity set name two other filter parameters

 

For eg.

 

http://nwfront.abc.net:2020/sap/opu/odata/sap/ZMY_SRV/allRulesSet?$filter=DepartmentID eq '1' and DepartmentName eq 'Testing'

 

 

Based on these filters, I want to get all the employees id and names in the get_entityset method in the export parameter et_entityset

 

Is it possible?

 

I don't want to include the Department ID and Department Name fields in the entity type as my model will have duplicates ( same values repeated) for these fields all over and unwanted columns.

 

Thanks and Regards,

Gopa

SAP Hybrid App Toolkit Installation Problem (Mac)

$
0
0

Hi Experts,

 

I'm trying to install the SAP Hybrid App Toolkit, but I'm receiving an ERROR:

"Cordova search plugin failure: you must configure the the HTTP(S) proxy correctly."

 

I tried to configure the Plugman and it seems to be okay. But if check it again, it's still the same error.

Even after restarting my Mac.

 

Do you have any ideas?

Create new entry in the ODataModel

$
0
0

Hello All,

 

After creating the ODataModel (sap.ui.model.odata.v2.ODataModel), I want to create in the model a new entry of a specific entity, and bind it to my controls, so the user can fill the attributes. This is what I do:

 

var oCtx = this.modelRef.createEntry("/OrderDetailGeneralSet", null);  oControl = this.getView().byId("GeneralOrderDataFragment");  oControl.setBindingContext(oCtx);

There is no entry created in the oData node of the model. What am I doing wrong?

 

Thanks,

Szilamér


Name retrieval in About Me card in ESS SAP UI5 Application

$
0
0

Hi,

 

For Japan, First Name (VORNA) field in IT 0002 is utilized to store Kanji name. The name in the About Me card header in HR Services - My Info - Employee Profile lane retrieves name from First Name (VORNA) field in Infotype 0002 Personal Data. The Romaji or Roman Alphabet names are stored in a separate field in IT 002. For Japan the First Name in About Me card appears in Kanji (Japanese script). Business wants easy identification of names and hence have requested that the name appearing in the About Me Card header (About "<<First Name>>") should appear in English. Can the following standard BADI's HRMSS_DR_FIELDS_EMP_PROFILE or HRMSS_DR_FIELDS_PERS_DATA be utilized to change the name retrieval in About Me card from one field to another of IT 0002?

clear the object in model in sapui5

$
0
0

Hi gurus,

                  I am still getting used to SAPUI5 and I am trying to clear the model with model.destroy() and it does not work, Is it not possible to delete the whole data in sapui5 , If that's the case , I would be really surprised.

 

Your early response is appreciated.

 

 

Thanks

Somil

 

Here is the screen shot of the console :

 

odata.JPG

Two-Way Binding with createEntry SAPUI5

$
0
0

I am trying to use Two-Way binding with a v2 OData model. In the route matched of the create view I have the following code.

 

this.getOwnerComponent().oWhenMetadataIsLoaded.then(function() {  var oEntry = oView.getModel().createEntry("/ContactCollection");  oView.setBindingContext(oEntry);
}.bind(this));  }.bind(this));

At runtime i call the screen and update a value in the create view that is "bound" to the model.

 

Then in my save function I have been executing the following line in the debugger.

 

this.getView().getBindingContext().getObject()

The output is a blank entity will all properties set to "undefined".

 

While searching I found this page

 

So i implemented line

 

oView.getModel().setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

in the route matched function above with same results.

 

I have also tried using

 

oView.unbindElement();

from the discussion here

 

Any help would be appreciated.

CSS issues when setting data-sap-ui-prelaod="async"

$
0
0

Hi! I was trying setting data-sap-ui-preload="async", but this for some fitting reasons made my style.css rendering all weird. If I set it to sync or remove the data-sap-ui-preload line from bootstrap script tag then my css gets rendered correctly.

 

Below is my bootstrap with css link.

 

<script id="sap-ui-bootstrap" type="text/javascript"

             src="resources/sap-ui-cachebuster/sap-ui-core.js"

             data-sap-ui-libs="sap.ui.commons,

            sap.ui.core, sap.ui.table, sap.m, sap.ui.ux3, sap.suite.ui.commons, sap.uiext.inbox"

             data-sap-ui-theme="sap_bluecrystal"

             data-sap-ui-compatVersion="edge"

             data-sap-ui-preload="async"

             data-sap-ui-resourceroots='{"UIPROJ": ""}'>

     </script>

    

<link rel="stylesheet" type="text/css" href="css/style.css">

 

Anyone came across this? Also I noticed in some tutorials/walkthroughs/examples that the stylesheet link is missing entirely form the index.html file...where and how do they implement it then?

Temporary contents during initial load

$
0
0

Hi,


the initial load of my UI5 application takes a couple of seconds on older smartphones. During the loading time, I would like to present some intermediate contents. It is pretty simple to get stuff on the index.html page by using the sap.ui.getCore().attachInit(...) method. For example:


sap.ui.getCore().attachInit(function () {  new sap.m.Text({            text: "Hello World"  }).placeAt("content");
});
sap.ui.getCore().attachInit(function () {  sap.ui.require([  "zink/model/mockserver",  "sap/m/Shell",  "sap/ui/core/ComponentContainer"  ], function (mockserver, Shell, ComponentContainer) {  mockserver.init();  new Shell({  app: new ComponentContainer({  name: "zink",  height: "100%"  })  }).placeAt("content");  });
});

Problem is, that the intermediate part remains on the page even after the contents of my application has been loaded and displayed. I would like to remove the intermediate contents once the real contents is loaded. Any suggestions how I can achieve that?


Thanks!

Viewing all 6178 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>