Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
delete a row - predefined formatter
30/07/2011
03:46
Avatar
dhoover
Member
Members
Forum Posts: 23
Member Since:
28/12/2008
sp_UserOfflineSmall Offline

I 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});
 });

30/07/2011
20:56
Avatar
dhoover
Member
Members
Forum Posts: 23
Member Since:
28/12/2008
sp_UserOfflineSmall Offline

are there any COMPLETE working examples of this that I can download from somewhere. I love jqGrid, but the documentation could be better.

02/08/2011
02:16
Avatar
wyattbiker
Member
Members
Forum Posts: 8
Member Since:
13/07/2011
sp_UserOfflineSmall Offline

dhoover 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.:

{name: 'actions', index: 'actions',  title:false, align:'center', width:50, formatter: imageButton}

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;

}

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information