【发布时间】:2011-11-05 05:25:10
【问题描述】:
使用下面的 colmodel 将操作按钮添加到 jqGrid 列。 列宽 45 足以容纳同一行中的两个按钮。 编辑和删除按钮出现在单独的行中,并且行高增加。 由于未知原因,两个按钮前都有空白,没有出现在列的左侧。
如果内联编辑开始,保存和取消按钮也会出现在单独的行中。
如何在增加列宽的情况下强制按钮出现在同一行?
grid.jqGrid({
colModel: [{name:_actions,width:45,
formatter:"actions",
formatoptions:
{keys:true}
}, ....
更新
工具栏包含按钮右侧的文本。从样式中删除 30px 会创建重叠按钮,因此我无法删除它。
根据我添加的 Oleg 建议
.ui-inline-edit, .ui-inline-del, .ui-inline-save, .ui-inline-cancel
{
margin-right: 0px !important;
}
和
colModel: [{"hidden":false,"label":" Muuda ","name":"_actions","width":($.browser.webkit == true? 58: 53)
,"align":"center","sortable":false,"formatter":"actions","formatoptions":{"keys":true,"delbutton":false,"onSuccess":function (jqXHR) {
actionresponse = jqXHR;
return true;
}
,"afterSave":function (rowID) {
cancelEditing($('#grid'));aftersavefunc(rowID,actionresponse)}
,"onError":errorfunc
,"extraparam":{"_dokdata":FormData
},"afterRestore":setFocusToGrid
,"onEdit":function (rowID) {
if (typeof (lastSelectedRow) !== 'undefined' && rowID !== lastSelectedRow)
cancelEditing($('#grid'));
lastSelectedRow = rowID;
}
}},
样式,但这不会改变任何东西,按钮仍然出现在两行中。如何解决?
更新 2
添加 fixed: true 将按钮放到同一行。 有两个问题:
按钮很小
列仅包含编辑按钮(使用了 delbutton:false 选项)。 编辑按钮宽度小,图标不居中。 如何将编辑按钮宽度增加到列宽 - 几个像素,以便单击列中的任意位置启动编辑模式并在列中心显示编辑图标? 如何增加保存广告取消按钮的宽度,使两者都占用 50%- 几个像素的操作列宽度?
多次快速点击会导致编辑按钮停止工作
保存按钮与编辑按钮出现在同一位置,保存到服务器需要一些时间。 如果快速单击此位置,则在保存完成之前切换内联编辑模式并且自动完成控件 不再创建。 之后,编辑按钮根本不起作用。 如何防止多次保存按钮点击:如果点击一次或其他解决方案禁用保存按钮或整个网格并显示“正在保存...”消息直到保存完成?
使用的样式:
td.ui-pg-button > div.ui-pg-div { margin-right: 30px }
colmodel:
colModel: [{
fixed:true,
label:" Change ",
name:"_actions",
width:($.browser.webkit == true? 58: 53)
,align:"center",
sortable:false,
formatter:"actions",
formatoptions:{"keys":true,"delbutton":false,
"onSuccess":function (jqXHR) {actionresponse = jqXHR;return true;}
,"afterSave":function (rowID) {
cancelEditing($('#grid'));aftersavefunc(rowID,actionresponse);actionresponse=null; }
,"onError":errorfunc
,"extraparam":{"_dokdata":FormData
},
afterRestore:setFocusToGrid
,onEdit:function (rowID) {
if (typeof (lastSelectedRow) !== 'undefined' && rowID !== lastSelectedRow)
cancelEditing($('#grid'));
lastSelectedRow = rowID;
}
}}
【问题讨论】:
-
在您的演示(测试用例)中,我使用的设置仍未包含。您应该只跟踪您使用的样式或更新您的测试用例。
标签: jqgrid