- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章ASP.NET MVC异步获取和刷新ExtJS6 TreeStore由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
从数据库获取构造树结构是ExtJS TreePanel的核心技术,常用方法是TreeStroe里配置proxy,这种方式的root成了一个不受控制的节点.
TreeStroe的root实际是一个层叠json数据,大部分情况是直接写一些简单数据,但在实际应用中必定是要从数据库读取的。我的方法是先用Ext.Ajax.request获取root数据形成TreeStroe。定义一个全局的TreeStroe名字是mTreeStore,用Ext.Ajax.request获得root数据。TreeStoreRefresh函数与此类似,将mTreeStore的root换为新值。TreePanel的rootVisible属性必须为true,增加一个节点单击事件显示节点的信息.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
var
mTreeStore =
null
;
Ext.Ajax.request({
async:
false
,
url:
'/api/BasicData_API/GetBasicTablesTreeSource'
,
method:
'get'
,
success:
function
(response, options)
{
var
TreeRoot = Ext.decode(response.responseText);
mTreeStore = Ext.create(
'Ext.data.TreeStore'
,
{
root: TreeRoot
});
},
failure:
function
(response, options)
{
//var responseArray = Ext.decode(response.responseText);
Ext.Msg.alert(
'服务器错误'
,
'数据处理错误原因:\n\r'
+ response.responseText);
}
});
function
TreeStoreRefresh()
{
Ext.Ajax.request({
async:
false
,
url:
'/api/BasicData_API/GetBasicTablesTreeSource'
,
method:
'get'
,
success:
function
(response, options)
{
var
TreeRoot = Ext.decode(response.responseText);
if
(mTreeStore !=
null
)
{
mTreeStore.setRoot(TreeRoot);
}
},
failure:
function
(response, options)
{
//var responseArray = Ext.decode(response.responseText);
Ext.Msg.alert(
'服务器错误'
,
'数据处理错误原因:\n\r'
+ response.responseText);
}
});
}
Ext.define(
'TreeToolbarCls'
, {
extend:
'Ext.toolbar.Toolbar'
,
padding:
'0 0 0 0'
,
items: [{
text:
'刷新'
,
iconCls:
'refresh'
,
handler: TreeStoreRefresh,
height: 30,
width: 65
}]
});
Ext.define(
'U1TreeCls'
,
{
extend:
'Ext.tree.Panel'
,
xtype:
'U1Tree_xtype'
,
//title: '基础数据字典',
rootVisible:
true
,
width: 300,
store: mTreeStore,
scrollable:
true
,
tbar:Ext.create(
'TreeToolbarCls'
),
listeners:
{
itemclick: NodeClick
}
});
function
NodeClick(node, record, item, index, e, eOpts)
{
if
(
typeof
(record.data) ==
"undefined"
)
{
return
;
}
var
message = Ext.String.format(
'Level={0}<br/>state={1}'
, record.data.Level, record.data.state);
Ext.Msg.alert(
"节点信息"
, message);
}
|
下面是后台C#代码 。
定义一个TreeNode类,包含TreePanel节点固有的一些属性,也可以任意扩充,利用这个可以自定义许多附加数据,如我在里面定义Level表示节点的级别.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
[Authorize]
[RoutePrefix(
"api/BasicData_API"
)]
public
class
BasicData_APIController : ApiController
{
[Route(
"GetBasicTablesTreeSource"
)]
public
HttpResponseMessage GetBasicTablesTreeSource(
string
condition =
null
)
{
List<TreeNode> lstF =
new
List<TreeNode>();
ZydAdonet z = ZydAdonet.Instance();
string
s1 =
"select TableName,title from BaseDataTables order by TableName"
;
string
sqltext = s1;
DataTable dt1;
string
ErrMes;
z.Sql2DTReadOnly(s1,
out
dt1,
null
,
out
ErrMes);
TreeNode tnd;
foreach
(DataRow drx
in
dt1.Rows)
{
tnd =
new
TreeNode
{
id = drx[
"TableName"
].ToString(),
text = drx[
"title"
].ToString(),
Level = 1,
iconCls =
"table_6"
,
state = drx[
"TableName"
].ToString() +
" OK"
,
leaf =
true
};
lstF.Add(tnd);
}
TreeNode root =
new
TreeNode
{
text =
"基础数据字典"
,
expanded =
false
,
iconCls =
"folder_close"
,
Level = 0,
state =
"RootOfTree"
,
leaf =
true
};
if
(lstF.Count > 0)
{
root.expanded =
true
;
root.leaf =
false
;
root.iconCls =
"folder_open"
;
root.children = lstF;
}
string
JsonStr;
JsonStr = JsonConvert.SerializeObject(root);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK,
"value"
);
response.Content =
new
StringContent(JsonStr, Encoding.GetEncoding(
"UTF-8"
),
"application/json"
);
response.Headers.CacheControl =
new
CacheControlHeaderValue()
{
MaxAge = TimeSpan.FromMinutes(10)
};
return
response;
}
}
internal
class
TreeNode
{
public
string
id {
get
;
set
; }
public
string
text {
get
;
set
; }
public
string
iconCls {
get
;
set
; }
public
string
state {
get
;
set
; }
public
bool
leaf {
get
;
set
; }
public
int
Level {
get
;
set
; }
public
bool
expanded {
get
;
set
; }
public
List<TreeNode> children {
get
;
set
; }
}
|
在NodeClick函数中断可以监视到更多的信息:
最后的运行效果:
然后更改数据表里的数据,点“刷新”就实现了TreePanel节点的刷新.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
最后此篇关于ASP.NET MVC异步获取和刷新ExtJS6 TreeStore的文章就讲到这里了,如果你想了解更多关于ASP.NET MVC异步获取和刷新ExtJS6 TreeStore的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我带着这么简单的问题来到这里,但找不到它......无论如何,你可以在下面看到代码。这是里面有项目的面板。我想要的是更改名称为“intIP”的文本字段的值,它位于面板内部,位于面板内部。我怎样才能做到
如何在 ExtJS 设计中显示面包屑功能。 我正在使用带边框布局的面板,我想在面板顶部设计面包屑功能 请寄给我一些 sample ..... 提前致谢 最佳答案 我想到了两个解决方案。 使用面板标题
你好 如何在 ExtJS 中设计嵌套网格 请提供一些示例(如何在 ExtJS GridPanel 中使用 RowExpander) 最佳答案 尝试这样的事情: //Create the Row Ex
我有类似的东西 Ext.define('HS.controller.Utility', { statics : { state : 'Oklahoma' } }); 现在我想
我有一列checkcolumn类型来启用切换 bool 值。我希望能够一次为该值切换所有行。理想情况下,我可以在checkcolumn header 中添加一个复选框,并监听更改。那可能吗? 我想指出
在我的 extjs 项目中,我有一些 panel我要展示的toolbar在 mouseEnter事件。这工作正常。但是当我用新的 html 更新面板时,mouseenter事件不起作用。 panel.
如何在 ExtJs Combo 中显示图标和显示字段。extjs 组合是否有任何扩展。请提供一些 sample 。 最佳答案 对于 ExtJS4,将带有 getInnerTpl 方法的 listCon
我有用于网格和柱状图的存储,但值是字符串形式的(服务器端格式化的数量,不能在客户端完成)。由于字符串格式的数量,网格没有被呈现。解决方案可能会使用网格和图表所需的数据类型制作单独的存储。但这是低效的方
我正在一个页面上有一个GridPanel的项目中工作。该面板可以显示任意数量的行,并且我设置了autoHeight属性,这将导致GridPanel扩展以适合行数。我现在想要一个水平滚动条,因为在某些分
我有一个网格,它允许用户通过编辑行来输入数字。我希望数字支持 4 位小数,但它只支持 2 位。我想出了如何显示 4 位小数,但它没有注册超过 2 位小数。 因此,如果用户输入 1000.1111,结果
我这里有以下网格: Ext.define('AM.view.user.List', { extend: 'Ext.grid.Panel', alias: 'widget.userlis
我正在将我的应用程序从ExtJs 3迁移到4版本。 我的formPanel上有几个组合框,以前我用过hiddenName 以及所有的stuff提交valueField而不是displayField。
我在一个面板中创建了多个项目。现在我想以“适合”布局显示此面板。我不想修复该面板的高度和宽度。我知道“适合”布局只允许显示一项。 这里可以使用“适合”布局吗?或者有什么替代方案可以实现这一目标吗? 谢
我需要将数据库值加载到组合框中。我不明白,为什么值没有加载到组合框中。通过 firebug,打印出 console.log 值。这是我的组合框代码, var groups = new Ext.data
这是将筛选器动态添加到gridpanel底部工具栏的正确语法吗? this.Grid.getBottomToolbar().plugins=[filters]; 当我这样做时没有错误。但是,它的行为并
我正在使用ExtJS v4.0。 在客户端和服务器端之间维护日期格式确实令人困惑。 用户需要自己的输入格式,但是服务器通常要求提交为一种标准格式。 它应该是ExtJS中的内置实现,但不是。 我已经阅读
我的问题对你来说很容易,但我负担不起..我从行中获取数据并显示在其他面板的字段中我的目标是编辑这些数据并在网格中显示编辑后的数据,请给我一些建议,我知道它需要 commit() 函数但是.. 我的代码
我是 ExtJS 的新手。我遵循了一个教程,目的是在网格上创建分页。代码很简单,我发现它很可疑......结果,分页工具栏在那里,但在第一次加载时仍然显示所有数据。这是我在 View 文件中的代码:
听说EXTJS是一个独立于浏览器的javascript库。 extjs 如何使自己独立于浏览器?当我打开库类时,我没有看到任何代码: 如果(IE)//这样做;else if (FF)//做其他事情;
我有一个类的实例(例如 Ext.data.Model)myRecord 并且需要调用它的静态方法之一(例如 getFields())。我该怎么做? 最佳答案 您还可以使用 self获取类的属性: my
我是一名优秀的程序员,十分优秀!