在我的數據庫我有一列兩個選項:如何在一個jqgrid列中添加兩種格式?
- /uploads/1369839038.zip
- NULL
現在我已在「電子郵件」一欄中格式化,以便它顯示爲一個鏈接,
formatter:function(cellvalue, options, rowObject){
return '<a href="' + cellvalue + '"target="_blank">FILES </a> '
} }
但我想讓它顯示空白,如果它有「空」這樣JQGRID show blank instead of Null或顯示爲像我的鏈接格式化已經有。我想在一個格式化程序中將這兩個「附件」列組合起來,以便根據數據顯示鏈接或空白。請非常感謝一些幫助。
我的jqGrid
$(function(){
$("#list").jqGrid({
url:'request.php',
editurl: "jqGridCrud.php",
datatype: 'xml',
mtype: 'GET',
height: 'AUTO',
width: 850,
scrollOffset:0,
hidegrid: false,
colNames:['id','Project', 'Assigned To','Assign Date','Check Date','Due Date','Attachments','Notes',""],
colModel :[
{name:'id', index:'id', width:28, align: 'center'},
{name:'name', index:'name', width:170, align:'left',editable:true, editoptions:{
size:60} },
{name:'id_continent', index:'id_continent', width:50, align:'right',editable:true,edittype:'select',
editoptions:{value: "Henry:Henry; Ramon:Ramon; Paul:Paul" },mtype:'POST' },
{name:'lastvisit', index:'lastvisit', width:55, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm/d/yy',editable:true, edittype: 'text',mtype:'POST' , editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} ,
{name:'cdate', index:'cdate', width:55, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm/d/yy', edittype: 'text',editable:true ,mtype:'POST' ,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} ,
{name:'ddate', index:'ddate', width:55, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm/d/yy',date:'true',editable:true, edittype: 'text',editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} ,
{name:'files', index:'files', width:50,align:'center',sortable:false,mtype:'POST',formatter:function(cellvalue, options, rowObject){
return '<a href="' + cellvalue + '"target="_blank">FILES </a> '
} },
{name:'notes', index:'notes', width:100, align:'left',sortable:false, editable:true,edittype:'textarea', editoptions:{
rows:5,cols:60,maxlength:200} },
{name:'act', index:'act',width:30 ,align:'left', sortable:false,formatter: "actions",cellattr: function() { return ' title="Delete Project"'; },
formatoptions: {
keys: true,
deltitle: 'delete',
delbutton: true,
editbutton:false,
delOptions: {
url: 'delete-perm.php',
afterShowForm: function ($form) {
$("#dData", $form.parent()).click();
},
msg: "Remove Selected Project?",
bSubmit: "Remove",
bCancel: "Cancel"
}
}},
],
pager: '#pager',
rowNum:30,
rowList:[30,40,80],
sortname: 'ddate',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: 'Current Assignments',
ondblClickRow: function(rowid) {
$(this).jqGrid('editGridRow', rowid,
{width:550,Height:550,recreateForm:true,closeAfterEdit:true,
closeOnEscape:true,reloadAfterSubmit:true, modal:true,mtype:'post',top:350,left: 30});}
});
jQuery.extend(jQuery.jgrid.nav, {
deltitle: '',
delcaption: 'Project Complete'
},{delicon: "ui-icon-circle-check",deltext: "Project Complete"});
$("#list").jqGrid("navGrid", "#pager", { add: false, search: false, refresh:false,edit:false }).navButtonAdd('#pager',{
caption:"Export to Excel",
buttonicon:"ui-icon-save",
onClickButton: function() {
jQuery("#list").jqGrid('excelExport', { url: 'ExportExcel.php' });
},
position:"last"
});
// setup grid print capability. Add print button to navigation bar and bind to click.
setPrintGrid('list','pager','Current Assignments');
});
請任何幫助表示讚賞。 – NewHistoricForm