Mmarset
Mmarset

Reputation: 149

SAPUI5 My fragment gets closed

I'm Developing SAPui5 APP. I create a fragment xml with a sap.m.Popover, In Content of Popover I add 2 sap.m.MultiCombobox. When I close the selection of multicombobox my popover gets closed. Any solution?

Fragment code:

<core:FragmentDefinition
  xmlns="sap.m"
  xmlns:l="sap.ui.layout"
  xmlns:core="sap.ui.core">
  <Popover
    class="sapUiPopupWithPadding"
    title="Filtro Asignación"
    placement="Top" >
  <l:VerticalLayout>
    <Label text="Fecha"   ></Label>
    <DatePicker id="idDatePickerPopover"></DatePicker>
    <Label text="Zona"   ></Label>
    <MultiComboBox id="idZonaCombo" selectionFinish="selectionCombo" items="{path: '/AsGrShlpCollection',sorter: { path: 'AsGrDesc' }}">
        <core:Item key="{AsGrId}" text="{AsGrDesc}" />
    </MultiComboBox>
    <Label text="Asignación"></Label>
    <MultiComboBox id="idAsignado" selectionFinish="selectionCombo" items="{path: '/DAsDescShlpCollection',sorter: { path: 'DAsDesc' }}">
        <core:Item key="{DAsDescId}" text="{DAsDesc}" />
    </MultiComboBox>
  </l:VerticalLayout>
    <footer>
      <Toolbar>
        <ToolbarSpacer/>
        <Button
          text="Aceptar"
          press="aplicarFiltros" />
        <Button
          text="Cancelar"
          press="cancelarFiltros" />
      </Toolbar>
    </footer>
  </Popover>
</core:FragmentDefinition>

Controller function Code:

aplicarFiltros: function(oEvent){
        var oDatePicker = sap.ui.getCore().byId("idDatePickerPopover");
        var oMultiCombo = sap.ui.getCore().byId("idZonaCombo");
        var oMultiComboAsignado = sap.ui.getCore().byId("idAsignado");
        var sDate = oDatePicker.getDateValue().toString();// pasamos la fecha a string
        var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern : "yyyyMMdd" });  //le damos formato 
        var dateFormatLabel = sap.ui.core.format.DateFormat.getDateInstance({pattern : "dd/MM/yyyy" });
        var sDateStr = dateFormat.format(new Date(sDate));
        var sDateLabel = dateFormatLabel.format(new Date(sDate));

        var filters= [new sap.ui.model.Filter("AsDate",sap.ui.model.FilterOperator.EQ, sDateStr)];// creamos array filtros y añadimos el de fecha

        var lSelectedItems = oMultiCombo.getSelectedItems();//cogemos los items selecionados del Combo 
        var sLabelzone="";

             for (var i = 0; i < lSelectedItems.length; i++) {//loop para pushear en el array todos los filtros seleccionados 
                filters.push(new sap.ui.model.Filter("AsGrId",sap.ui.model.FilterOperator.EQ,lSelectedItems[i].getKey()));
                sLabelzone = sLabelzone + lSelectedItems[i].getText();
                sLabelzone = sLabelzone + " ";


        }
        var sLabeltipo="";

        var lSelectedItemsCombo2 = oMultiComboAsignado.getSelectedItems();

            for (var i = 0; i < lSelectedItemsCombo2.length; i++) {//loop para pushear en el array todos los filtros seleccionados 
                filters.push(new sap.ui.model.Filter("DAsDescId",sap.ui.model.FilterOperator.EQ,lSelectedItemsCombo2[i].getKey()));
                sLabeltipo = sLabeltipo + lSelectedItemsCombo2[i].getText();

            }


        jQuery.sap.require("jquery.sap.storage");
        var oStorage = jQuery.sap.storage(jQuery.sap.storage.Type.local);   
        oStorage.put("arrayFilters",filters);// guardamos los filtros en el Storage

        this.getView().byId("master1List").getBinding("items").filter(filters);// bindeamos y aplicamos filtros 
        // this.getView().byId("master1List").setHeaderText(sDateLabel+" | "+sLabelzone+" | "+sLabeltipo);
        sap.ui.getCore().byId("idDatePop").setText(sDateLabel);
        sap.ui.getCore().byId("idZonaPop").setText(sLabelzone);
        sap.ui.getCore().byId("idAsignPop").setText(sLabeltipo);




    },

Upvotes: 2

Views: 1839

Answers (1)

Dani&#235;l Camps
Dani&#235;l Camps

Reputation: 1809

Try setting the 'modal' property if your sap.m.Popover to true. This prevents it from closing when you click outside of the popover area.

Upvotes: 2

Related Questions