Forum



14:12

17/02/2010

When deleting / adding a row, I need to send additional parameter in form of POST data. By default, only "oper" and "id" paramters being sent over. Let's say I need to delete / add based on "user_id" (a foreign key of the dataset), how can I put it into the POST data?
This is what I tried but didnt work.
onclickSubmit: function(rowid) {
var val = $('#tags').getCell(rowid, 'user_id');
return {user_id:val};
}
Please help....I can't delete or add anything.
14:33

17/02/2010

I can get the post data working but couldn't get the user_id from the grid
jQuery("#tags").jqGrid({
url:'admin.lists.tags.subgrid.process.php?k=kiskool&list_id=0',
editurl: "admin.lists.tags.subgrid.process.php?k=kiskool&list_id=0",
datatype: "json",
mtype: "POST",
colNames:['id','tag','record_status_type_id','list_id'],
colModel:[
{name:'id', index:'id', width:100},
{name:'tag', index:'tag', width:200, editable:true},
{name:'record_status_type_id', index:'record_status_type_id', width:200},
{name:'list_id', index:'list_id', width:100}
],
pager: '#pagernav2',
rowNum:10,
rowList:[10,20,30,40,50,100],
sortname: 'id',
sortorder: "asc",
caption: "Manage Lists-Tags Association",
height: 200
});
jQuery("#tags").jqGrid('navGrid','#pagernav2',
{add:true,edit:false,del:true,search:false}, //options
{}, // edit options
{mtype:"POST",closeAfterAdd:true,reloadAfterSubmit:true,
onclickSubmit: function(rowid){
var val = $('#tags').getCell(rowid, 'list_id');
return {list_id:val};
}
}, // add options
{mtype:"POST",reloadAfterSubmit:true,
onclickSubmit: function(rowid){
var val = $('#tags').getCell(rowid, 'list_id');
return {list_id:val};
}
}, // del options
{} // search options
);
This part always returns false: var val = $('#tags').getCell(rowid, 'list_id');
Any clue??
20:10

04/11/2009

I would suggest you create a custom button:
http://www.trirand.com/jqgridw.....om_buttons
1. you can use the pre-submit events to store global variables holding the rowid and the cellvalue (your userid).
2. then have a custom button function that triggers an ajax post:
example….
.jqGrid('navButtonAdd','#jQGridpager',{buttonicon:'ui-icon-wrench',
onClickButton:function(){$.post('my-delete-url?rowid=therow&user=userid');},caption:'Delete!'});
[edit: if your post already works then just read #1 and store the cellvalue in a variable]
tim
17:29

17/02/2010

Tim,
I tried custom buttons, but it's a little different from what you've suggested. I can now delete and add but still having problem with it. Let me explain the situation in detail...
I'm having a master grid that lists out all book lists. When I click on a book list, it will list out the users who subscribed that book list in another gridvew (detail gridview). I followed the example from the demo page, "Master Detail", http://www.trirand.com/blog/jq.....qgrid.html.
What I want to do is to be able to add / delete users from the detail gridview. Literally, I can add / delete users of a book list. The problem now is that when I delete a user of a book list and then I click on another book list and try to delete the user, it doesn't delete that user. I don't see any problem with add.
$("#del").click(function(){
var gr = jQuery("#tags").jqGrid('getGridParam','selrow');
if( gr != null ) {
var val = jQuery('#tags').jqGrid('getCell',gr,'list_id');
jQuery("#tags").jqGrid('delGridRow',gr, {reloadAfterSubmit:true,
onclickSubmit: function(params){alert(val); return {list_id:val};}});
}
else { alert("Please select row to delete!"); }
});
I notice that the culprit was the on the onclickSubmit event. If you see the code, I'm trying to get the list_id from the gridview ("val" variable), and it is fine. Inside the onclickSubmit event, I try to display the "val", but it always displays the previous list_id.
Is this a bug? Or, is this probably cache? If yes, how to clear it?
I did exactly the same thing for add, I could get the correct list_id everytime.
$("#add").click(function(){
var gr = jQuery("#tags").jqGrid('getGridParam','selrow');
if( gr != null ) {
var val = jQuery('#tags').jqGrid('getCell',gr,'list_id');
jQuery("#tags").jqGrid('editGridRow','new', {closeAfterAdd:true, reloadAfterSubmit:true,
onclickSubmit: function(params){return {list_id:val};}});
}
else {
alert("Please put cursor on the grid!");
}
});
18:07

17/02/2010

Finally solve it. There was a mistake in the previous code, it should be like the following.
$("#del").click(function(){
var gr = jQuery("#tags").jqGrid('getGridParam','selrow');
if( gr != null ) {
jQuery("#tags").jqGrid('delGridRow',gr, {reloadAfterSubmit:true,
onclickSubmit: function(params){
var gr = jQuery("#tags").jqGrid('getGridParam','selrow');
var val = jQuery('#tags').jqGrid('getCell',gr,'list_id');
return {list_id:val};}});
}
else { alert("Please select row to delete!"); }
});
Most Users Ever Online: 715
Currently Online:
61 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