Forum
Topic RSS
03:46
28/12/2008
OfflineI may as well be new to jqGrid, since this is the first time I've used it in 2 years! Anyway, I am attempting to construct a grid with a delete icon in the first column of each row, no editing is allowed, just delete. In the examples under predefined formatter I saw a grid similar to what I want to do, except that it also allowed editing. I get it to paint correctly, but I really do not understand what I need to do to make the delete operation actually do the right thing. When I watch what goes on in firebug, I see it fires off an http request to ajax.php with no parameters. I guess I am somehow supposed to provide that, but I really do not know how to do it. At minimum, I would like to provide an operation (delete) and a row id, so I can have the server code take care of the deletion. Anyway, what follows is the code. If someone could enlighten me, I would appreciate it.
jQuery(document).ready(function() {
jQuery("#list1").jqGrid({
url:'ajax.php',
datatype:"xml",
colNames:[' ', 'Keyword','Competition','Searches','CPC'],
colModel:[
{name:'myac', width:25, fixed: true, sortable:false,resize:false,formatter:'actions',formatoptions:{editbutton:false,delbutton:true}},
{name:'keyword',index:'keyword', width:300},
{name:'competition',index:'competition', width:80, align:'right'},
{name:'searches',index:'searches', width:70, align:'right'},
{name:'cpc',index:'cpc', width:40, align:'right'}
],
rowNum:10,
autowidth:false,
rowList:[10,20,30],
pager:jQuery('#pager1'),
sortname:'id',
sortorder:"desc",
caption:"XML Example",
editurl: 'ajax.php'
}).navGrid('#pager1',{edit:false,add:false,del:false});
});
02:16
13/07/2011
Offlinedhoover said:are there any COMPLETE working examples of this that I can download from somewhere. I love jqGrid, but the documentation could be better.
You can set a column formatter like this (just hard code a value in your XML). You can then in your function add the row ID to execute the action.:
function imageButton (cellvalue, options, rowObject){
cv=cellvalue;
cellvalue='<a onclick="alert(\'Delete '+cv+' \' ); return false;"><img class="ui-icon ui-icon-trash" title="Delete" style="float:left"/></a>';
return cellvalue;
}
Most Users Ever Online: 994
Currently Online:
17 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66
Log In
Home