Forum


13:56

22/05/2009

Hello,
I am pretty new to jqgrid and jquery and I was having some problems with subgrids and using navigator controls with the subgrid. I am trying to use a subgrid inside a master grid and everything is coming out ok so far. I want to be able to search the mastergrid and the subgrid independently from each other and managed to get the mastergrid working fine with single filter search and refresh.
The subgrid has the whole gambit of nav buttons and I can't seem to get the search working for the subgrid and was hoping someone could help me out. Also, when the delete function works, both the master and the subgrid get refreshed. Is it possible for the refresh to only work on the subgrid when there is a delete and for that matter when you hit the refresh button on the subgrid.
Basically, how do i seperate the refresh on the subgrid from refreshing the whole thing?
Here is my code, the double pound sign is because we use coldfusion for serverside:
<cfoutput>
<script>
$(document).ready(function()
{
$('##filter').jqm();
var selectedRow = 0;
$("##list").jqGrid(
{
url:'include/getUsers3.cfc?method=getAccounts&PAID=#client.account_ID#',
datatype: 'json',
colNames:['account_ID','Account Name','Account Code','PA_ID'],
colModel :[
{name:'id',index:'id', width:70, sorttype:"int", hidden:true},
{name:'name',index:'name', width:350,resizable:true, align:"left",sorttype:"text",editable:false},
{name:'Account_Internal_ID',index:'Account_Internal_ID', width:500,resizable:true, align:"left",sorttype:"text",editable:false},
{name:'ParentAccount_ID',index:'ParentAccount_ID', width:70, sorttype:"int", hidden:true},
],
pager: $('##pager'),
rowNum:8,
rowList:[8,16,14,32,40],
sortorder: "asc",
sortname: "id",
viewrecords: true,
imgpath: '/test/script/images',
caption: 'Users *click button to open*',
height:'auto',
mtype:'GET',
recordtext:'Total Records',
pgtext:' of',
multiselect: false,
subGrid: true,
subGridRowExpanded: function(subgrid_id, row_id) {
var subgrid_table_id, pager_id;
subgrid_table_id = subgrid_id+"_t";
pager_id = "p_"+subgrid_table_id;
$("##"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
jQuery("##"+subgrid_table_id).jqGrid(
{
url:"include/getUsers3.cfc?method=getUsers&id="+row_id,
datatype: 'json',
colNames: ['userID','User Name','First Name','Last Name','Password','Email_ID','Email Address','Notify','Alias Login','Account','User Type','Hint_ID','Secret Word Hint','Secret Word','Login Count'],
colModel: [
{name:'userID',index:'userID', width:50,resizable:false, hidden:true, sorttype:"int",resizable:false,editrules:{readonly:true}},
{name:'UserName',index:'UserName', width:150,resizable:true, sorttype:"text",editable:true,edittype:"text",editoptions:{size:30,maxlength:50},editrules:{required:true}},
{name:'FirstName',index:'FirstName', width:250,resizable:true, align:"left",sorttype:"text",editable:true,edittype:"text",editoptions:{size:50,maxlength:80},editrules:{required:true}},
{name:'LastName',index:'LastName', width:130,resizable:true, align:"left",sorttype:"text",editable:true,edittype:"text",editoptions:{size:50,maxlength:80}},
{name:'Password',index:'Password', width:150,resizable:true,align:"left",sorttype:"text",editable:true,edittype:"text",editoptions:{size:30,maxlength:50},editrules:{required:true}},
{name:'Email_ID',index:'Email_ID', width:50,resizable:false, hidden:true, sorttype:"text",resizable:false,editrules:{readonly:true}},
{name:'EmailAddress',index:'EmailAddress', width:150,resizable:false,hidden:true,align:"left",sorttype:"text",editable:true,edittype:"text",editoptions:{size:50,maxlength:80},editrules:{edithidden:true}},
{name:'Notify',index:'Notify', width:50,resizable:false, sortable:false, hidden:true, editable:true,edittype:"select",editoptions:{value:"0:No;1:Yes"},editrules:{edithidden:true}},
{name:'Alias',index:'Alias', width:50,resizable:false,align:"left",hidden:true,sorttype:"text",editable:true,edittype:"text",editoptions:{size:30,maxlength:50},editrules:{edithidden:true}},
{name:'Account',index:'Account', width:50,resizable:false,hidden:true,align:"left",sorttype:"int",resizable:false,editrules:{readonly:true}},
{name:'Status',index:'Status', width:50,resizable:false, sortable:false, hidden:true, editable:true,edittype:"select",editoptions:{value: "1:Investor;2:Client;-1:Other;-2:Super User [hide files];-3:Site Manager [delete files]"},editrules:{edithidden:true,required:true}},
{name:'HintID',index:'HintID', width:50,resizable:false, hidden:true, sorttype:"text",resizable:false,editrules:{readonly:true}},
{name:'Hint',index:'Hint', width:50,resizable:false, sortable:false, hidden:true,editable:true,edittype:"select",editoptions:{value: "#HintList#"},editrules:{edithidden:true}},
{name:'SecretWord',index:'SecretWord', width:50,resizable:false, sortable:false,hidden:true, editable:true,edittype:"text",editoptions:{size:30,maxlength:50},editrules:{edithidden:true}},
{name:'LoginCount',index:'LoginCount', width:80,resizable:false, sortable:false,editrules:{readonly:true}},
],
rowNum:20,
rowList:[20,30,40,50],
pager: pager_id,
imgpath: '/test/script/images',
sortname: 'user_id',
sortorder: "asc",
viewrecords: true,
recordtext:'Total Records',
pgtext:' of',
editurl:"include/getUsers3.cfc?method=addeditUser&aid="+row_id,
height: '100%',
jsonReader: {
root: "ROWS2",
page: "PAGE2",
total: "TOTAL2",
records:"RECORDS2",
userdata:"USERDATA2",
cell: "",
id: "0"
}
})
$("##"+subgrid_table_id).navGrid(
"##"+pager_id,{edit:true,add:true,del:true,view:true,search:true,refresh:true,edittext:"EDIT",addtext:"ADD",viewtext:"VIEW",deltext:"DELETE",searchtext:"SEARCH",refreshtext:"REFRESH"},
{reloadAfterSubmit:false,closeAfterEdit:true,width:"600",height:"275"},
{reloadAfterSubmit:false,closeAfterAdd:true,width:"600",height:"275"},
{url:"include/getUsers3.cfc?method=delUser",closeAfterDelete:true,reloadAftersubmit:false,caption:"Delete User",msg:"Delete selected User(s)",width:"400"}
);
$.extend($.jgrid.search,{
caption:"Filter",
Find:'Search',
width:'400',
checkInput:true,
model:true,
sopt: ['bw','ew','cn']
});
},
subGridRowColapsed: function(subgrid_id, row_id) {
//var subgrid_table_id;
//subgrid_table_id = subgrid_id+"_t";
//jQuery("##"+subgrid_table_id).remove();
},
toolbar:[true,"top"],
loadComplete:function(){
$("##t_list").html(recorddata.MSG);
},
jsonReader: {
root: "ROWS",
page: "PAGE",
total: "TOTAL",
records:"RECORDS",
cell: "",
id: "0"
}
});
$("##t_list").css("color","red");
$("##list").navGrid("##pager",{add:false,edit:false,del:false,view:false,search:true,refresh:true,searchtext:"SEARCH",refreshtext:"REFRESH"});
$.extend($.jgrid.search,{
caption:"Filter",
Find:'Search',
width:'400',
checkInput:true,
model:true,
sopt: ['bw','ew','cn']
});
}
);
</script>
</cfoutput>
Any and all help is much appreciated and I want to thank you all in advance.
02:48

Moderators
30/10/2007

Hello,
Wich version do you use? Could you please try with 3.4.4 or 3.5 beta?
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
10:41

22/05/2009

Okay, so I tried it with 3.5 beta and the refresh stuff is working independantly! Thank you!!
I am still working with the new search option stuff and will get back to you on how that goes.
The one thing I notice now is that the pager is not picking up the information from the jsonReader and not displaying the total records value or page count values. Any thoughts on how I can rectify this?
*** edit: figured it out. Had to remove recordtext and pgtext.
Thanks again for all your help.
Most Users Ever Online: 715
Currently Online:
67 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