这是我的视图部分,如PurchaseReport.js
Ext.define("App.view.tabs.PurchaseReport", {
extend: "Ext.panel.Panel",
alias: "widget.PurchaseReportTab",
requires: [
"App.model.PurchaseReport", "Ext.toolbar.Toolbar"
],
border: false,
layout: "fit",
items: [
App.Util.buildBrowseConfig({}, {
controller: "PurchaseReport",
primaryKeyField: "PurchaseReportId",
stateful: true,
stateId: "App.view.windows.PurchaseReport-grid",
columns: [
{ dataIndex: "PurchaseCost", filter: true, header: "Purchase Cost", width: 150 }
],
features: [{ ftype: "filters", autoReload: false, local: true }],
store: { model: "App.model.PurchaseReport", sorters: [{ property: "Name", direction: "asc" }] }
})
]
});
这是我的控制器部分,我的网格绑定为PurchaseReport.js, 所以我需要在这里进行更改吗?
Ext.define("App.controller.tabs.PurchaseReport", {
extend: "Ext.ux.app.BrowseController",
views: ["tabs.PurchaseReport"],
refs: [
{
ref: "myPurchaseReportGrid",
selector: "PurchaseReportTab > gridpanel"
}
],
init: function () {
this.control({
PurchaseReportTab: {
bind: function (a, c) {
**//Grid bind start**
var b = this.getMyPurchaseReportGrid();
b.getSelectionModel().deselectAll();
b.store.removeAll();
b.fireEvent("bind", b, c)
**//Grid bind End**
**//Combobox Bind start**
var combo = this.getCoachCombo(),
store = combo.store,
options = store.lastOptions || {};
options = Ext.apply({
callback: function () {
combo.select(App.coach.CoachId)
//console.log("called rajesh");
}
}, options);
store.load(options);
if (App.coach.IsAdmin) {
combo.show()
}
**//Combobox Bind end**
var abilities = App.coach.Abilities,
toolbar = this.getToolbar();
for (var x = 0; x < abilities.length; x++) {
var ability = abilities[x],
button = toolbar.query("button[tooltip=" + ability.Name + "]");
if (button.length) {
button[0].setVisible(true)
}
}
}
},
"PurchaseReportTab > gridpanel": {
bind: this.bind,
itemdblclick: this.handleRecord,
selectionchange: this.selectionChange
}
})
}
});
这是我的模型零件名称PurchaseReport.js
Ext.define("App.model.PurchaseReport", {
extend: "Ext.data.Model",
fields: [
{
name: "PurchaseDate",
type: "date"
}
],
proxy: {
type: "ajax",
url: "ControllerFactory.aspx",
extraParams: {
controller: "PurchaseReport",
operation: "GetPurchaseReportsByCoachIdAndDates"
},
reader: {
type: "json",
root: "data",
successProperty: "success"
}
}
});
但是我能够在网格视图中显示记录,但我需要一个页脚区域,我可以显示购买总成本。在网格页脚
请不要发现代码错误,因为我删除了很多东西以使其看起来更简单,因为我是新手,请告诉我需要哪些更多细节。
我尝试添加代码,但它在Gridview显示记录的所有页面中显示页脚,我只想在一个页面中显示页脚而不在其他页面上显示页脚,并且还需要显示总计的购买成本
Ext.define("Ext.grid.Panel", {
extend: "Ext.panel.Table",
requires: ["Ext.grid.View"],
alias: ["widget.gridpanel", "widget.grid"],
alternateClassName: ["Ext.list.ListView", "Ext.ListView", "Ext.grid.GridPanel"],
viewType: "gridview",
lockable: false,
bothCfgCopy: ["invalidateScrollerOnRefresh", "hideHeaders", "enableColumnHide", "enableColumnMove", "enableColumnResize", "sortableColumns"],
normalCfgCopy: ["verticalScroller", "verticalScrollDock", "verticalScrollerType", "scroll"],
lockedCfgCopy: [],
rowLines: true,
//Newly addded start
height: 200,
width: 400,
bbar: [
{
xtype: 'textfield',
name: 'Total',
fieldLabel: 'Total',
allowBlank: false
}
],
renderTo: Ext.getBody()
//Newly addded end
});
答案 0 :(得分:3)
要放置页脚,您需要在代码中使用bbar
。在您定义网格及其配置的代码中,您需要编写
示例示例:
bbar: [
{
xtype: 'textfield',
name: 'Total',
fieldLabel: 'Total',
allowBlank: false
}
],
请阅读Documentation 以便更好地理解。 另外,我为你做了一个小提琴,这样你就可以关联你的项目和网格。 Fiddle
答案 1 :(得分:0)
要为某些特定页面添加网格视图的页脚,您需要在视图中将代码设置为(评论评论://为了向特定页面的网格视图添加页脚开始)
Ext.define("App.view.tabs.PurchaseReport", {
extend: "Ext.panel.Panel",
alias: "widget.PurchaseReportTab",
requires: [
"App.model.PurchaseReport", "Ext.toolbar.Toolbar"],
border: false,
layout: "fit",
items: [
App.Util.buildBrowseConfig({}, {
controller: "PurchaseReport",
primaryKeyField: "PurchaseReportId",
stateful: true,
stateId: "App.view.windows.PurchaseReport-grid",
columns: [
{ dataIndex: "PurchaseCost", filter: true, header: "Purchase Cost", width: 150 }
],
features: [{ ftype: "filters", autoReload: false, local: true }],
store: { model: "App.model.PurchaseReport", sorters: [{ property: "Name", direction: "asc" }],
//In order to add footer down to gridview for particular pages start
height: 200,
width: 400,
bbar: [
{
dataIndex:"PurchaseCost",
xtype: 'textfield',
name: 'Total',
fieldLabel: 'Total',
allowBlank: false
}
],
renderTo: Ext.getBody()
//In order to add footer down to gridview for particular pages end
}
})
]
});
答案 2 :(得分:0)
使用以下代码
Ext.define('Ext.grid.feature.Summary', {
/* Begin Definitions */
extend: 'Ext.grid.feature.AbstractSummary',
alias: 'feature.summary',
/* End Definitions */
/**
* Gets any fragments needed for the template.
* @private
* @return {Object} The fragments
*/
getFragmentTpl: function() {
// this gets called before render, so we'll setup the data here.
this.summaryData = this.generateSummaryData();
return this.getSummaryFragments();
},
/**
* Overrides the closeRows method on the template so we can include our own custom
* footer.
* @private
* @return {Object} The custom fragments
*/
getTableFragments: function(){
if (this.showSummaryRow) {
return {
closeRows: this.closeRows
};
}
},
/**
* Provide our own custom footer for the grid.
* @private
* @return {String} The custom footer
*/
closeRows: function() {
return '</tpl>{[this.printSummaryRow()]}';
},
/**
* Gets the data for printing a template row
* @private
* @param {Number} index The index in the template
* @return {Array} The template values
*/
getPrintData: function(index){
var me = this,
columns = me.view.headerCt.getColumnsForTpl(),
i = 0,
length = columns.length,
data = [],
active = me.summaryData,
column;
for (; i < length; ++i) {
column = columns[i];
column.gridSummaryValue = this.getColumnValue(column, active);
data.push(column);
}
return data;
},
/**
* Generates all of the summary data to be used when processing the template
* @private
* @return {Object} The summary data
*/
generateSummaryData: function(){
var me = this,
data = {},
store = me.view.store,
columns = me.view.headerCt.getColumnsForTpl(),
i = 0,
length = columns.length,
fieldData,
key,
comp;
for (i = 0, length = columns.length; i < length; ++i) {
comp = Ext.getCmp(columns[i].id);
data[comp.dataIndex] = me.getSummary(store, comp.summaryType, comp.dataIndex, false);
}
return data;
}
});