如何在extjs gridpanell中的每一行添加一个按钮

ext.grid.gridpanel增加一个按钮_百度知道
提问者采纳
按钮肯定是有专门的控件的,比如menu什么的grid只是表格显示框,用来显示信息的。
提问者评价
其他类似问题
ext的相关知识
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁户型图列显示的图片实际上就是一个超链接。
添加一个Button分2个步骤:1.在列头中定义超链接列或者Button列的HTML代码,也就是Render 2.添加该Button的事件处理函数。其中,gridPanel应作为参数传入该函数。
应该在gridPanel初始化时定义:
(1)cellClick的listener:cellClick
(2)cellClick事件的处理函数:onCellClick
列头定义的代码如下:
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(), //自动添加行号
header: "房间编号",
dataIndex: "RoomNumber",
//可以进行排序
sortable: true
header: "户型结构",
dataIndex: "huxingjiegou",
//可以进行排序
isHidden: true,
sortable: true
header: "面积(M²)",
dataIndex: "area",
//可以进行排序
sortable: true
header: "单价(元/M²)",
dataIndex: "singlePrice",
//可以进行排序
sortable: true
editor: new Ext.grid.GridEditor(new Ext.form.NumberField({
allowBlank: false
header: "总价(元)",
dataIndex: "totalPrice",
//可以进行排序
sortable: true
header: "面积(M²)",
dataIndex: "mianjiCC",
//可以进行排序
sortable: true
header: "单价(元/M²)",
dataIndex: "priceCCS",
//可以进行排序
sortable: true
editor: new Ext.grid.GridEditor(new Ext.form.NumberField({
allowBlank: false
header: "总价(元)",
dataIndex: "totalPriceCCS",
//可以进行排序
sortable: true
header: "面积(M²)",
dataIndex: "mianjiCK",
//可以进行排序
sortable: true
header: "单价(元/M²)",
header: "总价(元/M²)",
dataIndex: "priceCK",
//可以进行排序
sortable: true
editor: new Ext.grid.GridEditor(new Ext.form.NumberField({
allowBlank: false
header: "",
dataIndex: "totalPriceALL",
//可以进行排序
sortable: true
header: "户型图",
tooltip: "户型图",
width: 120,
locked: true,
menuDisabled: true,
sortable: false,
dataIndex: "huxingPic",
renderer: function (data, metadata, record, rowIndex, columnIndex, store) {
var picture = store.getAt(rowIndex).get('huxingPic');
return '&a href="' + picture + '"&' + '&img src="' + picture + '"width=60 hight=50& &/a&';
header: "订购",
renderer: function (value, meta, record) {
var formatStr = "&button
onclick='javscript:' class='order_bit'&订购&/button&";
var resultStr = String.format(formatStr);
return "&div class='controlBtn'&" + resultStr + "&/div&";
} .createDelegate(this),
css: "text-align:",
width: 30,
sortable: false
注意超链接为'&a href="' + picture + '"&',而按钮为return "&div class='controlBtn'&"
按钮处理事件的代码如下:
//按钮点击事件
grid.on('cellclick', function (grid, rowIndex, columnIndex, e) {
var btn = e.getTarget('.controlBtn');
var get = e.getTarget('.get');
if (get) {
var t = e.getTarget();
record = grid.getStore().getAt(rowIndex);
var control = t.classN
row = grid.getSelectionModel().getSelected(); //得到选择所有行
rowIndexId = rowI
this.GetRoomDetails(record, rowIndexId, projectName, loudongName); //传行一行记录直接加载
if (btn) {
var t = e.getTarget();
record = grid.getStore().getAt(rowIndex);
var control = t.classN
row = grid.getSelectionModel().getSelected(); //得到选择所有行
switch (control) {
case 'sale_already':
var state = "已售";
this.SetSaleState(record,state)
this.GetOrderManagement(record, state, rowIndexId, projectName, loudongName)
case 'order_bit':
var state = "大定";
this.SetSaleState(record,state)
this.GetOrderManagement(record, state, rowIndexId, projectName, loudongName)
阅读(...) 评论()在GridView 中点击某一个按钮在此按钮的下行动态添加一行,再次点击第二次添加的行隐藏 - 悟生慧 - 博客园
//页面内容
&asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" &&&&&&&&&&& onrowcommand="GridView1_RowCommand"&&&&&&&&&&&& &Columns&&&&&&&&&&&&&&&& &asp:TemplateField HeaderText="名称"&&&&&&&&&&&&&&&&&&&& &ItemTemplate&&&&&&&&&&&&&&&&&&&&&&&& &asp:Label ID="lblText" runat="server" Text='&%# Eval("V_Text") %&'&&/asp:Label&&&&&&&&&&&&&&&&&&&& &/ItemTemplate&&&&&&&&&&&&&&&& &/asp:TemplateField&&&&&&&&&&&&&&&& &asp:TemplateField HeaderText="键值"&&&&&&&&&&&&&&&&&&&& &ItemTemplate&&&&&&&&&&&&&&&&&&&&&&&& &asp:Label ID="lblCode" runat="server" Text='&%# Eval("V_Code") %&'&&/asp:Label&&&&&&&&&&&&&&&&&&&& &/ItemTemplate&&&&&&&&&&&&&&&& &/asp:TemplateField&&&&&&&&&&&&&&&& &asp:TemplateField&&&&&&&&&&&&&&&&&&&& &ItemTemplate&&&&&&&&&&&&&&&&&&&&&&&& &asp:LinkButton ID="lkBtn"& runat="server" CommandArgument='&%# Eval("V_Code") %&' CommandName="btnShow" &新增&/asp:LinkButton&&&&&&&&&&&&&&&&&&&& &/ItemTemplate&&&&&&&&&&&&&&&& &/asp:TemplateField&&&&&&&&&&&& &/Columns&&&&&&&& &/asp:GridView&
//后置代码&
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)&&& {&&&&&&& if (e.CommandName.Equals("btnShow"))&&&&&&& {&&&&&&&&&&& //创建一个GridView的一个分隔行(根据DataControlRowType来设置)&&&&&&&&&&& // GridViewRow rowSeparator = new GridViewRow(0, 0, DataControlRowType.Separator, DataControlRowState.Normal);&&&&&&&&&&& //或实现一个数据行&&&&&&&&&&& GridViewRow rowSeparator = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);&&&&&&&&&&& //设置行的底色&&&&&&&&&&& rowSeparator.BackColor = System.Drawing.Color.W&&&&&&&&&&& // 获取到行索引 RowIndex &&&&&&&&&&& GridViewRow gvrow = (GridViewRow)(((mandSource).NamingContainer);&&&&&&&&&&& int index = gvrow.RowI&&&&&&&&&&& //获得当前的GridView &&&&&&&&&&& GridView gv = (GridView)&&&&&&&&&&& //设置单元格集&&&&&&&&&&& TableCellCollection cells = gv.Rows[index].C&&&&&&&&&&& //设置单元格,根据实际情况增加,我这儿是增加一个跨所有列的行&&&&&&&&&&& TableCell separatorCell = new TableCell();&&&&&&&&&&& //根据GridView的第一列的显示情况设置单元格和跨列数&&&&&&&&&&& if (GridView1.Columns[0].Visible == true)&&&&&&&&&&& {&&&&&&&&&&&&&&& //当前增加的行所跨的列是gv 的所有列&&&&&&&&&&&&&&& separatorCell.ColumnSpan = cells.Count-1;&&&&&&&&&&& }&&&&&&&&&&& else&&&&&&&&&&& {&&&&&&&&&&&&&&& separatorCell.ColumnSpan = cells.Count - 1;&&&&&&&&&&& }&&&&&&&&&&&&&&& //}&&&&&&&&&&&&&&& //单元格的对齐&&&&&&&&&&&&&&& separatorCell.HorizontalAlign = HorizontalAlign.C&&&&&&&&&&&&&&& //单元格的背景色&&&&&&&&&&&&&&& separatorCell.BackColor = System.Drawing.Color.FromArgb(226, 226, 226);&&&&&&&&&&&&&&& //单元格的高度&&&&&&&&&&&&&&& separatorCell.ControlStyle.Height = 10;
&&&&&&&&&&&&&&& //在列中添加一个控件&&&&&&&&&&&&&&& TextBox tb = new TextBox();&&&&&&&&&&&&&&& //l.Text = "ddddd";&&&&&&&&&&&&&&& Control c = (Control)
&&&&&&&&&&&&&&& TextBox tbi = new TextBox();&&&&&&&&&&&&&&& Control ci = (Control)
&&&&&&&&&&&&&&& separatorCell.Controls.Add(c);&&&&&&&&&&&&&&& separatorCell.Controls.Add(ci);&&&&&&&&&&&&&&& //在单元格集中增加单元格控件&&&&&&&&&&&&&&& rowSeparator.Cells.Add(separatorCell);&&&&&&&&&&&&&&& //设置GridView行的可见性&&&&&&&&&&&&&&& rowSeparator.Visible =&&&&&&&&&&&&&&& //在GridView中的相应行插入行&&&&&&&&&&&&&&& GridView1.Controls[0].Controls.AddAt(index + 2, rowSeparator);&&&&&&&&&&&&&&& //判断当前按钮点了几次了 同一个按钮点击第一次是添加下面的一行,点击第二次死隐藏当前添加的行&&&&&&&&&&&&&&& //ViewState["flat"] 用于标记当前点了几行&&&&&&&&&&&&&&& if (ViewState["flat"] != null)&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&& if (ViewState["flat"].ToString().Trim().mandArgument.ToString()))&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&& rowSeparator.Visible =&&&&&&&&&&&&&&&&&&&&&&& ViewState["flat"] =&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&& else ViewState["flat"] = e.CommandArgument.ToString();&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&& else&&&&&&&&&&&&&&&&&&& ViewState["flat"] = e.CommandArgument.ToString();
&&&&&&&&&&&&&&& // 注意: ViewState["flat}= 在pageLoad 事件中要先创建
随笔 - 260当前位置: >
> ExtJs中的GridPanel取每一起其中一个字段的值,
ExtJs中的GridPanel取每一起其中一个字段的值,
tsmmaw & at
ExtJs中的GridPanel取每一行其中一个字段的值,急!!!!  DataTable&dt&=&DbHelperSQL.ExcuteQuery(sql);
for&(int&i&=&0;&i&$<$dt.Rows.C&i++)
&&&&string&id=dt.Rows[i]["ID"].ToString();
&我的意思就是从GridPane中取第i行的ID值.Rows[i]["ID"]&
  for&(var&i&=&0;&i&$<$bGrid.getStrore().getCount();&i++)&{
string&id=dt.Rows[i]["ID"].ToString();//这里的意思就是取bGrid的每行的ID字段的值,具体写法不知道
GridPanel中的第i行的ID字段怎么表示啊
麻烦各位帮忙!!!
  bGrid.getStrore().getAt(i).get('ID');
tspangu & &
& & (0)(0)引用:  JavaScript&code 1bGrid.getStrore().getAt(i).get('ID');说这种方法ruotianhan & &
& & (0)(0)
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-extjs的GridPanel,怎样在每一行加button,并且有响应函数?_百度知道
extjs的GridPanel,怎样在每一行加button,并且有响应函数?
,有了响应函数,并进行操作,不好意思?。此外?,怎样提交。因为我想把每一行的ID传回服务器没分了
提问者采纳
w3school.asp" target="_blank">http://www,通过获取每个递交事件name or id来进行不同的响应处理用JS写吧./example/://www.<a href="/example/jseg_examples
其他类似问题
extjs的相关知识
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 extjs gridpanel 行高 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信