我需要jqgrid在某些列中顯示一些特殊字符,如「<test>
」,嘗試使用autoencode=true
,但它將所有列都更改爲HTML編碼,就像我在其他一些列中有按鈕,需要編碼,我們可以爲特定列設置自動編碼嗎?有任何想法嗎?jqgrid沒有顯示特殊符號
編輯:我已經使用了格式化所建議的奧列格,但我遇到了問題,我曾在的cols,在那裏我需要編輯模式之間切換到「保存」按鈕,保存並完成」和‘取消’我我張貼的代碼,但我不知道如何隱藏之間切換/取消隱藏在編輯模式下的按鈕:
網格設置:
$("#list").jqGrid({
url: '<%= Url.Action("JSONData","CompanyInfo")%>',
datatype: 'json',
colNames: ['ID', 'Company', 'Address' , 'Employers ', ''],
colModel: [
{ name: 'ID', index: 'ID', align: 'left', sortable: false, editable: true, hidden: true },
{ name: 'Company', index: 'Company', align: 'left', sortable: false, editable: false, formatter: ConvertLineChartoBR },
{ name: 'Address', index: 'Address', editoptions: { size: 100 }, align: 'left', sortable: false, editable: true, edittype: 'textarea', formatter: ConvertLineChartoBR, unformat: ConvertLineChartoN },
{ name: 'Employers', index: 'Employers', editoptions: { size: 100 }, align: 'left', sortable: false, editable: true, edittype: 'textarea' },
{ name: 'act', index: 'act', editable: false, sortable: false, fixed: true, formatter: setupEdit}],
pager: $('#pager'),
autowidth: true,
shrinkToFit: true,
rowNum: currRecords,
rowList: [5, 10, 20, 50],
recordtext: "View Records {0} - {1} of {2}",
emptyrecords: "No records to view",
pgtext: "Page {0} of {1}",
sortorder: "desc",
viewrecords: true,
autoencode: true,
caption: 'Test'
});
SetupEdit(對於格式化)
function setupEdit(cellvalue,options,rowObject) {
var btnSave = "<input type='button' value='Save' style='display:none' onclick=\"$('#list').jqGrid('saveRow', '" + options.rowId + "', null, '<%= Url.Action("GridSave","Company")%>', null, aftersavefunc);\" />";
var btnSaveFinished = "<input type='button' value='Save & Finish' style='display:none' onclick=\"$('#list').jqGrid('saveRow', '" + options.rowId + "', null, '<%= Url.Action("GridSaveFinished","Company")%>', null, aftersavefunc);\" />";
var btnCancel = "<input type='button' value='Cancel' style='display:none' onclick=\"$('#list').jqGrid('restoreRow', '" + options.rowId + "', aftercancelfunc);\" />";
var Edit = "<input type='button' value='Edit' class='editButton' onclick=\"$('#list').jqGrid('editRow','" + options.rowId+ "',false,oneditfunc);\" />";
return btnSave + btnSaveFinished + btnCancel + Edit;
}
Ø n編輯(在編輯按鈕點擊)
function oneditfunc(result, x) {
// I need to unhide the button of the last column where buttons are populated in setupEdit
// On Edit click, i need to enable btnSave,btnSaveFinished and btnCancel
//Again on aftersavefunc/aftercancelfunc i need to reset back the column value to display on Edit button
}
謝謝。我可以用這種方式設置它,沒有任何問題。但是在編輯模式下,編輯按鈕需要用保存和取消按鈕來替換。我用setRowData做了這個。現在看起來我不能再使用它了。有關如何解決這個問題的任何建議? – remo 2012-01-31 21:18:44
@remo爲什麼不使用預定義的'formatter:'actions''?它做你需要的。如果您確實需要自己實現相同的功能,則可以在格式化程序中添加許多按鈕,但是應該隱藏一些按鈕:「「然後你可以顯示你需要顯示的按鈕,並隱藏不需要的按鈕,同樣的'formatter:'actions''。 – Oleg 2012-02-01 07:13:34
我無法使用預定義的動作,因爲我有更多的按鈕添加到編輯模式,我會嘗試做一些顯示在其他多個按鈕,其他隱藏。謝謝 – remo 2012-02-01 13:39:57