博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jQuery EasyUI使用教程之动态改变数据网格列
阅读量:7034 次
发布时间:2019-06-28

本文共 1061 字,大约阅读时间需要 3 分钟。

hot3.png

<>

使用'columns'属性可以很容易地定义数据网格列。如果您想要动态地改变列,这也非常容易。为了更改列,您可以重新调用datagrid方法并传递一个新的column属性。

创建数据网格

<
table
id
=
"tt"
title
=
"Frozen Columns"
class
=
"easyui-datagrid"
style
=
"width:550px;height:250px"
url
=
"data/datagrid_data.json"
singleselect
=
"true"
iconcls
=
"icon-save"
>
</
table
>
$(
'#tt'
).datagrid({
columns:[[
{field:
'itemid'
,title:
'Item ID'
,width:80},
{field:
'productid'
,title:
'Product ID'
,width:80},
{field:
'attr1'
,title:
'Attribute'
,width:200},
{field:
'status'
,title:
'Status'
,width:80}
]]
});

运行该网页,您将会看到:

动态改变数据网格列

当您想要更改列时,可以编写一些代码:

$(
'#tt'
).datagrid({
columns:[[
{field:
'itemid'
,title:
'Item ID'
,width:80},
{field:
'productid'
,title:
'Product ID'
,width:80},
{field:
'listprice'
,title:
'List Price'
,width:80,align:
'right'
},
{field:
'unitcost'
,title:
'Unit Cost'
,width:80,align:
'right'
},
{field:
'attr1'
,title:
'Attribute'
,width:100},
{field:
'status'
,title:
'Status'
,width:60}
]]
});

请记住我们已经定义了其他属性,例如URL、width、height等,因此不需要再一次定义它们,您只需要定义那些需要改变的即可。

动态改变数据网格列

下载该EasyUI示例:

有兴趣的朋友可以

转载于:https://my.oschina.net/u/2317468/blog/601693

你可能感兴趣的文章
[开源]KJFramework.Message 智能二进制消息框架
查看>>
MySQL Replication, 主从和双主配置
查看>>
特性(C#)
查看>>
Socket Connect问题
查看>>
C#语言和SQL Server数据库技术_程序数据集散地:数据库
查看>>
HTML5播放视频音频
查看>>
LCIS最长公共上升子序列!HDU-1423
查看>>
【Leetcode】142. Linked List Cycle II
查看>>
hdu4976 A simple greedy problem.
查看>>
hdu 5340 Three Palindromes
查看>>
(转) C++中基类和派生类之间的同名函数的重载问题
查看>>
hdu 5676 ztr loves lucky numbers
查看>>
angularjs中下拉框select option默认值
查看>>
SPEC2006移入docker后的运行问题
查看>>
poi 操作excel
查看>>
去哪网第一题
查看>>
wufabuquan
查看>>
CentOS 6.5 安装Nginx 1.7.4
查看>>
commander.js 制作简易的 MINA CLI 脚手架
查看>>
召回率与精确率
查看>>