[已解决]无法显示/隐藏用于使用JQGrid进行内联编辑的图标的问题 [英] [SOLVED] Problem to show/hide icon for Inline editing with JQGrid
本文介绍了[已解决]无法显示/隐藏用于使用JQGrid进行内联编辑的图标的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
专家,
我创建了具有内联编辑功能的JQGrid.
我必须去字段
拳头名称:必需
姓氏:不需要
我正在使用以下步骤更新我的现有记录.
- 带有编辑和删除"按钮的网格.
- 单击编辑",然后(编辑",删除"将被隐藏)和(保存",取消"将被显示).
- I已经从名字"文本框中清除了值.
- 我按下了提交按钮,然后它将显示类似名字:必填字段"的消息.这是正确的
- 我的按钮后面(保存",取消"将替换为编辑",删除这是错误的) 代码段:
- Grid with Edit and Delete button.
- Clicking on Edit then (Edit, Delete will be hide) and (Save,Cancel will be display).
- I have cleared value from FirstName textbox.
- I pressed submit button then it will display message like "First Name: Field is required" this is correct
- But behind this my button (Save, Cancel will replace with Edit,Delete this is wrong) Code snippet:
我想在以下功能中添加检查点
Hi
Experts,
I have created JQGrid with inline editing feature.
I have to fields
Fist Name : required
Last Name : not required
I am using following step to update my existing record.
I would like to put check point in the following function
function inplaceSave(id) {
//Check point is required for Any Validation violation or unsuccessful save
jQuery('#list').saveRow(id);
//if it is success then following method should called else couldn't
changeActionState('save', id);
}
以下是完整的代码:
Following is complete code:
jQuery(document).ready(function () {
//$.jgrid.defaults.loadtext = '';
jQuery("#list").jqGrid({
url: '@Url.Action("JQGridGetGridData", "TabMaster")',
datatype: 'json',
mtype: 'GET',
colNames: ['col ID', 'First Name', 'Last Name', ''],
colModel: [
{ name: 'colID', index: 'colID', width: 100, align: 'left', searchoptions: { sopt: ['eq', 'ne', 'cn']} },
{ name: 'FirstName', index: 'FirstName', width: 150, align: 'left', editable: true, editrules: { required: true, number: true, minValue: 40, maxValue: 100} },
{ name: 'LastName', index: 'LastName', width: 150, align: 'left', editable: true },
{ name: 'Edit', index: 'Edit', width: 70, align: 'center', editable: false, formatter: editFmatter, unformat: unformatEdit }
],
pager: jQuery('#pager'),
hidegrid: false,
rowNum: 100,
rowList: [10, 50, 100, 150],
sortname: 'colID',
sortorder: "asc",
viewrecords: true,
multiselect: false,
//rownumbers: true,
imgpath: '@Url.Content("~/Scripts/themes/steel/images")',
caption: 'Tab Master Information',
editurl: '@Url.Action("JQGridEdit", "TabMaster")'
}).navGrid('#pager', { edit: false, add: false, del: false, search: false, refresh: false });
});
function inplaceEdit(id) {
jQuery('#list').editRow(id);
changeActionState('edit', id);
}
function inplaceCancel(id) {
jQuery('#list').restoreRow(id);
changeActionState('cancel', id);
}
function inplaceSave(id) {
jQuery('#list').saveRow(id);
changeActionState('save', id);
}
function changeActionState(action, id) {
if (action == 'edit') {
jQuery('#action_edit_' + id).css('display', 'none');
jQuery('#action_delete_' + id).css('display', 'none');
jQuery('#action_save_' + id).css('display', 'block');
jQuery('#action_cancel_' + id).css('display', 'block');
}
else {
jQuery('#action_edit_' + id).css('display', 'block');
jQuery('#action_delete_' + id).css('display', 'block');
jQuery('#action_save_' + id).css('display', 'none');
jQuery('#action_cancel_' + id).css('display', 'none');
}
}
我还发布了此问题 ^ ].
如果有的话请给我帮助.
谢谢,
Imdadhusen
I have also posted this problem here[^].
Please provide me help if you have.
Thanks,
Imdadhusen
推荐答案
.jgrid.defaults.loadtext =''; jQuery(" ).jqGrid({ 网址:' @ Url.Action("JQGridGetGridData","TabMaster")', 数据类型:' json', mtype:' GET', colNames:[' col ID',' 名字',' 姓氏',' '], colModel:[ {名称:' colID',索引:' colID',宽度: 100 ,对齐:' 左',搜索选项:{sopt:[' ' ' cn']}}, {名称:' 名字',索引:' 名字',宽度: 150 ,对齐:' 左',可 true ,编辑规则:{必需: true ,minValue: 100 }}, {名称:' LastName',索引:' LastName',宽度: 150 ,对齐:' 左',可 true }, {名称:' 编辑',索引:' 编辑',宽度: 70 ,对齐:' 居中,可 false ,格式化程序:editFmatter,未格式化:unformatEdit} ], 传呼机:jQuery(' #pager'), hidegrid: false , rowNum: 100 , rowList:[ 10 , 50 , 100 , 150 ], 排序名称:' colID', 排序顺序:" , viewrecords: true , 多项选择: false , // 行数:true, imgpath:' @ Url.Content(〜/Scripts/themes/steel/images")', 标题:' 标签主信息', editurl:' @ Url.Action("JQGridEdit","TabMaster")' }).navGrid(' #pager',{ false ,添加: false ,del: false ,搜索: false ,刷新: false }); }); 函数inplaceEdit(id){ jQuery(' #list').editRow(id); changeActionState(' edit',id); } 函数inplaceCancel(id){ jQuery(' #list').restoreRow(id); changeActionState(' 取消',id); } 函数inplaceSave(id){ jQuery(' #list').saveRow(id); changeActionState(' 保存',id); } 函数changeActionState(action,id){ 如果(操作== ' 编辑' ){ jQuery(' #action_edit _' + id).css( ' 显示',' 没有显示); jQuery(' #action_delete _' + id).css( ' 显示',' 没有显示); jQuery(' #action_save _' + id).css( ' display',' block'); jQuery(' #action_cancel _' + id).css( ' display',' block'); } 其他 { jQuery(' #action_edit _' + id).css( ' display',' block'); jQuery(' #action_delete _' + id).css( ' display',' block'); jQuery(' #action_save _' + id).css( ' 显示',' 没有显示); jQuery(' #action_cancel _' + id).css( ' 显示',' 没有显示); } }
.jgrid.defaults.loadtext = ''; jQuery("#list").jqGrid({ url: '@Url.Action("JQGridGetGridData", "TabMaster")', datatype: 'json', mtype: 'GET', colNames: ['col ID', 'First Name', 'Last Name', ''], colModel: [ { name: 'colID', index: 'colID', width: 100, align: 'left', searchoptions: { sopt: ['eq', 'ne', 'cn']} }, { name: 'FirstName', index: 'FirstName', width: 150, align: 'left', editable: true, editrules: { required: true, number: true, minValue: 40, maxValue: 100} }, { name: 'LastName', index: 'LastName', width: 150, align: 'left', editable: true }, { name: 'Edit', index: 'Edit', width: 70, align: 'center', editable: false, formatter: editFmatter, unformat: unformatEdit } ], pager: jQuery('#pager'), hidegrid: false, rowNum: 100, rowList: [10, 50, 100, 150], sortname: 'colID', sortorder: "asc", viewrecords: true, multiselect: false, //rownumbers: true, imgpath: '@Url.Content("~/Scripts/themes/steel/images")', caption: 'Tab Master Information', editurl: '@Url.Action("JQGridEdit", "TabMaster")' }).navGrid('#pager', { edit: false, add: false, del: false, search: false, refresh: false }); }); function inplaceEdit(id) { jQuery('#list').editRow(id); changeActionState('edit', id); } function inplaceCancel(id) { jQuery('#list').restoreRow(id); changeActionState('cancel', id); } function inplaceSave(id) { jQuery('#list').saveRow(id); changeActionState('save', id); } function changeActionState(action, id) { if (action == 'edit') { jQuery('#action_edit_' + id).css('display', 'none'); jQuery('#action_delete_' + id).css('display', 'none'); jQuery('#action_save_' + id).css('display', 'block'); jQuery('#action_cancel_' + id).css('display', 'block'); } else { jQuery('#action_edit_' + id).css('display', 'block'); jQuery('#action_delete_' + id).css('display', 'block'); jQuery('#action_save_' + id).css('display', 'none'); jQuery('#action_cancel_' + id).css('display', 'none'); } }
我还发布了此问题 ^ ].
如果有的话请给我帮助.
谢谢,
Imdadhusen
I have also posted this problem here[^].
Please provide me help if you have.
Thanks,
Imdadhusen
我已经解决了自己的问题 ,使用修改后的功能 inplaceSave 并添加了新功能 checkSave .
这是更新的代码.
Hi,
I have solved this problem my self, Using modified function inplaceSave and added new function checkSave.
Here is the updated code.
var rowid;
function inplaceSave(id) {
rowid = id;
jQuery('#list').saveRow(id, checkSave);
}
function checkSave(result) {
if (result.responseText.toLowerCase() == 'success') {
changeActionState('save', rowid);
refreshGrid();
}
}
谢谢,
Imdadhusen
Thanks,
Imdadhusen
这篇关于[已解决]无法显示/隐藏用于使用JQGrid进行内联编辑的图标的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文