handleColFilterPress: function(oEvent) {
//var _productTable, _activeTablesFilters = {}; define these two as global variables
//_productTable = _oView.byId("productTable");
var oValue = oEvent.getParameter("item").getValue();
var oBindingPath = this.getView().getModel().getProperty("/bindingValue"); //Get Hold of Model Key value that was saved
//create new filter object
var oFilter = new Filter(oBindingPath, "Contains", oValue);
_activeTablesFilters[_productTable.getId()][oBindingPath] = oFilter;
var oItems = _productTable.getBinding("items");
var allFilters = [];
//iterate and fetch filter for each column of current table
for (var key in _activeTablesFilters[_productTable.getId()]) {//key corresponds to a column
allFilters.push(_activeTablesFilters[_productTable.getId()][key]);
}
oItems.filter(allFilters, "Application");//apply filters
//put the code to close the popup here
},
<mvc:View id="downloadTable" xmlns:mvc="sap.ui.core.mvc" controllerName="portal.controllers.DownloadTable"
xmlns="sap.m" xmlns:layout="sap.ui.layout">
<Page showHeader="false" enableScrolling="true" class="sapUiContentPadding"
showNavButton="false">
<content>
<Table width="50%" id="productTable" growing="true" growingThreshold="10" items="{path: '/ProductCollection',sorter: { path: 'ProductId', descending: 'true' }}">
<headerToolbar>
<OverflowToolbar width="auto" height="27px" design="Transparent" visible="true" enabled="true">
<content>
<ToolbarSpacer width=""/>
<OverflowToolbarButton id="clearTabFilters" type="Transparent" visible="false" icon="sap-icon://clear-filter" iconFirst="true" width="auto" enabled="true" tooltip="Clear All Filters" iconDensityAware="false" press="clearTableFilters"/>
<OverflowToolbarButton type="Transparent" icon="sap-icon://download" iconFirst="true" width="auto" enabled="true" tooltip="Download Table Data" iconDensityAware="false" press="productTableExport"/>
</content>
</OverflowToolbar>
</headerToolbar>
<columns>
<Column>
<Text text="Name" />
</Column>
<Column>
<Text text="Status" />
</Column>
<Column>
<Text text="Supplier" />
</Column>
<Column>
<Text text="Category" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{Name}" />
<Text text="{Status}" />
<Text text="{SupplierName}" />
<Text text="{MainCategory}" />
</cells>
</ColumnListItem>
</items>
</Table>
</content>
<footer>
<OverflowToolbar id="otbFooter">
<ToolbarSpacer />
<Button text="Order" press="onOrder">
<layoutData>
<OverflowToolbarLayoutData
moveToOverflow="false" />
</layoutData>
</Button>
</OverflowToolbar>
</footer>
</Page>
</mvc:View>
productTableExport: function(oEvent) {
this.tableExportDownload(_productTable,
{
path : "/ProductCollection"
},
// column definitions with column name and binding info for the content
[{
name : "Name",
template : {
content : "{Name}"
}
}, {
name : "Status",
template : {
content : "{Status}"
}
}, {
name : "Supplier",
template : {
content : "{SupplierName}"
}
}, {
name : "Category",
template : {
content : "{MainCategory}"
}
}],
"ProductCollection"
);
},
tableExportDownload: sap.m.Table.prototype.exportData || function(oTable,rowJsonObj,colJsonArray,oFileName, modelName) {
var rows = rowJsonObj;
var oFilters = [];
for(var key in _activeTablesFilters[oTable.getId()]) {
oFilters.push(_activeTablesFilters[oTable.getId()][key]);
}
rows = {
path : rowJsonObj.path,
filters:oFilters
};
var oExport = new Export({
// Type that will be used to generate the content. Own ExportType's can be created to support other formats
exportType: new sap.ui.core.util.ExportTypeCSV({
separatorChar: "\t",
mimeType: "application/vnd.ms-excel",
charset: "utf-8",
fileExtension: "xls"
}),
// Pass in the grid table model created
models : (modelName)?oTable.getModel(modelName):oTable.getModel(),
// binding information for the rows aggregation
rows : rows,
// column definitions with column name and binding info for the content (from caller)
columns : colJsonArray
});
// download export
oExport.saveFile(oFileName).always(function() {
this.destroy();
});
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
25 | |
21 | |
12 | |
9 | |
9 | |
8 | |
8 | |
8 | |
7 |