gpt4 book ai didi

extjs - 如何在 Ext.grid.panel 中定义 View

转载 作者:行者123 更新时间:2023-12-02 03:48:11 25 4
gpt4 key购买 nike

我想修改网格的 View ,我从基础开始(即在我定义自己的 View 之前)。但是有些我什至无法将对象分配给查看属性。拜托,有人知道如何创建 View 吗?我试过跟随。

例子会很棒。

var viewConfig = {emptyText: "My msg",stripeRows: false};

this.grid = Ext.create('Ext.grid.Panel', {
id: "t-"+this.gridName+"-grid",
header: true,
title: gridTitle,
border: false,
store: store,
columns: cm,
selModel: sm,
loadMask: true,
//viewConfig: viewConfig, // works fine
//view: new Ext.view.Table() ,//Ext.grid.View(),//Ext.grid.View(viewConfig ),
provider: this.page.provider
});

如果我取消注释“view: new Ext.view.Table()”行,那么它会引发错误并停止一切。我一直在评论,在创建网格后,我可以使用 this.grid.getView() 属性访问 View 。但是如何创建自己的 View 对象(我可以在其中分配自定义模板)???

非常感谢。

最佳答案

来自文档:

This is the base class for both Ext.grid.View and Ext.tree.View and is not to be used directly.

如果您确实想自己创建一个,则需要配置以下必需 选项。

itemSelector : String
store : Ext.data.Store
tpl : String/String[]

into the docs如何创建自定义 View 。祝你好运!如果您需要任何帮助,请随时提出;)

Ext.define('Image', {
extend: 'Ext.data.Model',
fields: [
{ name:'src', type:'string' },
{ name:'caption', type:'string' }
]
});

Ext.create('Ext.data.Store', {
id:'imagesStore',
model: 'Image',
data: [
{ src:'http://www.sencha.com/img/20110215-feat-drawing.png', caption:'Drawing & Charts' },
{ src:'http://www.sencha.com/img/20110215-feat-data.png', caption:'Advanced Data' },
{ src:'http://www.sencha.com/img/20110215-feat-html5.png', caption:'Overhauled Theme' },
{ src:'http://www.sencha.com/img/20110215-feat-perf.png', caption:'Performance Tuned' }
]
});

var imageTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div style="margin-bottom: 10px;" class="thumb-wrap">',
'<img src="{src}" />',
'<br/><span>{caption}</span>',
'</div>',
'</tpl>'
);

var theView = Ext.create('Ext.view.View', {
store: Ext.data.StoreManager.lookup('imagesStore'),
tpl: imageTpl,
itemSelector: 'div.thumb-wrap',
emptyText: 'No images available'
});

var grid = Ext.create('Ext.grid.Panel', {
id: "t-"+this.gridName+"-grid",
header: true,
title: gridTitle,
border: false,
store: store,
columns: cm,
selModel: sm,
loadMask: true,
view: theView,
provider: this.page.provider,
renderTo: Ext.getBody()
});
//not tested but should work

关于extjs - 如何在 Ext.grid.panel 中定义 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15569202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com