在jqgird的内联编辑中如何检查是否选择了任何行?
我想显示错误消息"请选择一行!"当用户点击编辑而不选择任何行时。
@Oleg这里是代码:
gridobject.jqGrid({
url: getUrl,
datatype: 'json',
mtype: 'Get',
colNames: arryDisplayCol,
colModel: arryColSettings,
pager: jQuery(pPagerName),
rowNum: 20,
rowList: [20, 40, 80, 100],
height: '100%',
viewrecords: true,
loadonce: false,
grouping: false,
caption: caption,
emptyrecords: 'No records to display',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
Id: "0",
},
sortable: {
update: function (relativeColumnOrder) {
var grid = gridobject;
var currentColModel = grid.getGridParam('colModel');
$.ajax({
url: urls.Common.ArrangeGridOrder,
type: 'POST',
data: JSON.stringify(currentColModel),
contentType: 'application/json; charset=utf-8',
success: function (response) {
},
error: function (xhr, status, error) {
}
});
}
},
autowidth: true,
shrinkToFit: true,
multiselect: IsCheckbox,
editData: myData,
sortname: arrColSettings[0].name,
editurl: urls.Admin.ProcessRequest,
serializeRowData: function (postdata) {
var tableNames = $("#grdData").getGridParam('caption').replace(' List', '');
var columnNames = $("#grdData").getGridParam('colNames');
var colNames = columnNames.toString();
for (var i = 0; i < columnNames.length; i++) {
var colName;
if (columnNames[i] == "Id") {
colName = "Id"
}
}
if (!colName) {
colName = columnNames[1].toString();
}
var sel_id = $("#grdData").getSelectedRowsIds();
rowData = jQuery("#grdData").getRowData(sel_id);
var colValue = rowData[colName];
return { x01: JSON.stringify(postdata), x02: tableNames, x03: colNames, x04: JSON.stringify(jsonType), x05: colName, x06: colValue };
},
reloadAfterSubmit: true,
}).navGrid(pPagerName, {
edit: false,
add: false,
del: false,
search: false,
refresh: true,
refreshtext: "Refresh",
beforeRefresh: function () {
var tableName = $("#grdData").getGridParam('caption').replace(' List', '');
ReloadGrid(tableName);
},
});
gridobject.jqGrid('inlineNav', pPagerName,
{
edit: true,
editicon: "ui-icon-pencil",
add: true,
addicon: "ui-icon-plus",
save: true,
saveicon: "ui-icon-disk",
cancel: true,
cancelicon: "ui-icon-cancel",
editParams: {
keys: false,
oneditfunc: null,
successfunc: function (val) {
if (val.responseText != "") {
var tableName = $("#grdData").getGridParam('caption').replace(' List', '');
ReloadGrid(tableName);
}
},
url: null,
aftersavefunc:null,
errorfunc: null,
afterrestorefunc: null,
restoreAfterError: true,
mtype: "POST",
alertcap: "Warning",
alerttext: "Please, select row"
},
addParams: {
useDefValues: true,
addRowParams: {
keys: true,
extraparam: {},
successfunc: function (val) {
if (val.responseText != "") {
var tableName = $("#grdData").getGridParam('caption').replace(' List', '');
ReloadGrid(tableName);
}
}
}
}
}
);
答案 0 :(得分:0)
inlineNav
会自动测试是否选中该行。如果没有选择该行,那么带有文字&#34;请选择行&#34;将显示。默认文本来自$.jgrid.nav.alerttext
文件中定义的grid.locale-en.js
或您使用的其他语言文件。如果您的问题需要修改默认文本&#34;请选择行&#34;到&#34;请选择一行!&#34;那么你应该使用alerttext
的{{1}}选项(选项应该与navGrid
在同一级别定义)。