Posts

SAPUI5 - Sorting NumericString in xml view

  numericStringComparator : function ( a , b ) { return ( parseInt ( a , 10 ) || 0 ) - ( parseInt ( b , 10 ) || 0 ); } In your xml view : Binding with items in sap.m.Table < Table id = "idMyTable" inset = "false" items = " { path : '/Items' , // Your Collection sorter : { path : 'ItemNo' , // Your string property name comparator : '.numericStringComparator' } } " updateFinished = "onMyableUpdateFinished" >

Javascript - validateThaiID

Image

SAPUI5 - oDataV4 - Query with $top=500

  var sPath = "/ToBeApprovedList" ,           oModel = this . getView (). getModel (),           oListBinding = oModel . bindList ( sPath ); oListBinding . requestContexts ( 0 , 500 ). then ( oResult => {           oResult = { value : oResult . map ( x => x . getObject ()) };           if ( oResult . value ) {           that . setModel ( new JSONModel ({ value : oResult . value }), "approvalData" ); } });

SAPUI5 - Drag & Drop Row on List (Re-order Rows)

  <List      id = "idAttachList" headerText = "{i18n>piList}" items = " {      path : 'sendFileData>/Attach' } " mode = "MultiSelect" updateFinished = "onAttachListUpdateFinished" selectionChange = "onAttachListSelectionChange" > <dragDropConfig>           <dnd:DragDropInfo sourceAggregation = "items"                targetAggregation = "items"                dropPosition = "Between"                drop = "onAttachRowMove" /> </dragDropConfig>      <items>      <CustomListItem>           </CustomListItem> </items> </List> //------ controller.js onAttachRowMove : function ( oEvent ) {      var sDropPositio...

SAPUI5 - Disable Checkbox on List

  <List      id = "idAttachList" headerText = "{i18n>piList}" items = " {      path : 'sendFileData>/Attach' } " mode = "MultiSelect" updateFinished = "onAttachListUpdateFinished" selectionChange = "onAttachListSelectionChange" >      <items>      <CustomListItem>           </CustomListItem> </items> </List> onAttachListUpdateFinished : function ( oEvent ) {      var oList = oEvent . getSource (),      oItems = oList . getItems (); oList . selectAll (); oItems . forEach (( oItem ) => {      oItem . getMultiSelectControl ( true ). setEnabled ( false ); }); }

SAPUI5 - use btoa / atob in case of Base64.js is not initial

Image
Example in case of Base64 object is not defined. You can use default encode/decode from browser instead. var base64Id = ( typeof Base64 === "object" ) ?                          Base64 . encode ( oForm ) :                          window . btoa ( unescape ( encodeURIComponent ( oForm ))) Another example of btoa / atob . var sUnicodeText = "SAPUI5 🚀" ; var sEncodedUnicode = window . btoa ( unescape ( encodeURIComponent ( sUnicodeText ))); var sDecodedUnicode = decodeURIComponent ( escape ( window . atob ( sEncodedUnicode )));

SAPUI5 - Convert String to Date and vise versa

Image
this . _stringToDate ( "20260501" , "yyyyMMdd" ); this . _dateToString ( dTo , "yyyyMMdd" ); //dTo = new Date()